【问题标题】:Facebook Graph API to Post to Page not working on new serverFacebook Graph API 发布到页面无法在新服务器上运行
【发布时间】:2017-01-05 21:58:17
【问题描述】:

所以我一直在我的共享托管服务器上使用以下代码,它一直运行良好,但现在我们已经转移到专用服务器,但这个脚本不起作用?

专用服务器有 CentOS 6.8、Apache 2.2、PHP 7.0.14、MySQL 5.6 并安装了 curl。

我也在使用永久访问令牌。

$data['access_token'] = '{my permanent access token}';

$post_url = 'https://graph.facebook.com/{my feed ID}/feed';

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $post_url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$return = curl_exec($ch);
curl_close($ch);

$dec = (Array)json_decode($return);

$link = "https://www.facebook.com/".$dec["id"];

我在控制台中找不到任何错误,有什么方法可以调试吗?

【问题讨论】:

    标签: php mysql facebook facebook-graph-api curl


    【解决方案1】:

    想通了。我没有在旧服务器上强制使用 SSL,而是在新服务器上强制使用,因此需要在 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 之后添加以下行

    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
    

    【讨论】:

      猜你喜欢
      • 2012-06-18
      • 1970-01-01
      • 2014-08-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多