Q:
PHP/CURL Facebook graph call not working
Using PHP and CURL, I'm trying to pull the 'birthday' information for users from a Facebook page. I've been using the example on Facebook's developer page here, but it's still not working (I'm pulling the birthday information from the first couple of rows of data).
The example on the developer page is as follows:
$fields = array(
'method' => 'fql.query',
'query' => 'SELECT name, birthday, pic_square FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me())'
);
$params = array(
'access_token' => 'your-facebook-app-token',
'api' => '2.1',
'query' => $fields
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "".$username."/picture");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
$data = curl_exec($ch);
$d= json_decode($data);
curl_close($ch);
echo "Birthday Information for ". $username. "";
echo $d->{'name'};
echo $d->{'birthday'};
As you can see, I've taken the code from the developer example, but changed the access_token, api and so on. I'm getting the error:
curl_setopt(): Could not resolve host: me()
Which is referring to the next line of the example code:
'query' => 'SELECT name, birthday, pic_square FROM user WHERE uid IN (SELECT uid2
Related links:
Comments