Curl 28连接超时中遇到错误

时间:2019-07-15 07:30:30

标签: facebook curl

  

Facebook调试器卷曲错误:卷曲错误:28(OPERATION_TIMEOUTED)

我正在使用WordPress,并制作了一个新插件来推动Facebook在FB墙的每个URL共享上抓取我的页面。我将时间执行设置为300,但仍然面临相同的问题

function send_post($url, $post)
{

  $r = curl_init();
  curl_setopt($r, CURLOPT_URL, $url);
  curl_setopt($r, CURLOPT_POST, 1);
  curl_setopt($r, CURLOPT_POSTFIELDS, $post);
  curl_setopt($r, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt($r, CURLOPT_CONNECTTIMEOUT, 120);
  curl_setopt($r, CURLOPT_TIMEOUT, 120);
  $data = curl_exec($r);
  curl_close($r);
  return $data;
}

function getToken()
{

  $r = curl_init();
  curl_setopt($r, CURLOPT_URL, 'https://graph.facebook.com/oauth/access_token');
  curl_setopt($r, CURLOPT_POST, 1);
  curl_setopt($r, CURLOPT_POSTFIELDS, array( 'client_id' => yourclinet_id, 'client_secret' => 'yourclinet_secret', 'grant_type' => 'client_credentials' ));
  curl_setopt($r, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt($r, CURLOPT_CONNECTTIMEOUT, 30);
  $data = curl_exec($r);
  curl_close($r);
  return $data;
}

Facebook调试器给我一个错误-

  

卷曲错误
  卷曲错误:28(OPERATION_TIMEOUTED)

1 个答案:

答案 0 :(得分:0)

已解决错误。我在同一文件上调用了Curl。我分离了curl代码并解决了问题。感谢您的检查