Facebook Graph API requests take LONG? (file_get_contents)
I am us开发者_Python百科ing file_get_contents to retrieve stuff from the Facebook graph API (e.g: https://graph.facebook.com/me) and it takes like 5-10 seconds per request.
Any known issues on why this could be happening? When I ping the url from the browser it is really fast. Could it be a setting on my server?
It is possible. Use this cURL function :
function get_url($url)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 5);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
$tmp = curl_exec($ch);
curl_close($ch);
return $tmp;
}
Does it work faster?
精彩评论