6
To collect statistics from a shared Facebook URL in PHP, I am using Curl to query the following URI:
// URL para submeter
$pageUrl = 'http://www.example.com/my-new-article-is-neat';
// URI a consultar
$uri = 'https://graph.facebook.com/fql?q=';
$uri.= urlencode("SELECT like_count, total_count, share_count, click_count, comment_count FROM link_stat WHERE url = \"{$pageUrl}\"");
/* cURL it
*/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_URL => $uri
));
$resp = curl_exec($curl);
curl_close($curl);
Where we get:
{
"data": [
{
"like_count": 0,
"total_count": 0,
"share_count": 0,
"click_count": 0,
"comment_count": 0
}
]
}
Then we can use the result as follows:
$respObj = json_decode($resp);
var_dump($respObj->data[0]->total_count); // int(0)
Question
How can I perform the same operation in Python?