Facebook Graph API请求需要LONG吗? (的file_get_contents)

时间:2011-02-15 20:00:44

标签: php facebook facebook-graph-api

我正在使用file_get_contents从Facebook图形API中检索内容(例如:https://graph.facebook.com/me),每次请求需要5-10秒。

关于为什么会发生这种情况的任何已知问题?当我从浏览器ping网址时,它真的很快。它可能是我服务器上的设置吗?

1 个答案:

答案 0 :(得分:3)

有可能。使用此cURL函数:

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;
}

它运作得更快吗?