开发者

Facebook Graph API requests take LONG? (file_get_contents)

开发者 https://www.devze.com 2023-02-11 19:23 出处:网络
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.

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

精彩评论

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