Function returns post URLs rather than retrieving Facebook Graph API data

the_permalink() function doesn’t return the post permalik, it prints the permalink. To assing the permalink value to $url variable you need to user get_the_permalink() instead:

$url = get_the_permalink();