Reputation: 155
Is it possible to get somebody's Facebook name by ID?
It's possible to get it by file_get_contents but it's disabled on my server I'm afraid. I believe there's a curl work around but I've not used much curl before so I'm not quite sure what to use.
$pageContent = file_get_contents('http://graph.facebook.com/1157451330');
$parsedJson = json_decode($pageContent);
echo $parsedJson->name;
Any help is greatly appreciated.
Upvotes: 2
Views: 1685
Reputation: 76656
You can use cURL, like so:
$url = 'http://graph.facebook.com/4?fields=name';
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch,CURLOPT_URL,$url);
$result = curl_exec($ch);
curl_close($ch);
$result = json_decode($result);
echo $result->name;
Output:
Mark Zuckerberg
Upvotes: 3