开发者

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?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜