首页 > 解决方案 > Curl 28 连接超时面临错误

问题描述

Facebook 调试器 curl 错误:Curl 错误: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)

标签: facebookcurl

解决方案


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


推荐阅读