php - 用于发布到页面的 Facebook Graph API 无法在新服务器上运行

标签 php mysql facebook facebook-graph-api curl

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

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

我也在使用永久访问 token 。

$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"];

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

最佳答案

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

之后添加以下行
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);

关于php - 用于发布到页面的 Facebook Graph API 无法在新服务器上运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41495450/

相关文章:

mysql - 选择最新的行,忽略旧的重复项

ios - 如何通过 react native 发布 ios 应用程序

php - 如何让我的 PHP 脚本每天在特定时间运行?

php - 如何避免在邮件功能中显示 HTML 标签

javascript - 如何通过AJAX、PHP传递复选框值?

mysql - Ruby-mysql 问题 - 尝试将 mysql 模块用于 Ruby 时出错

mysql - 尾随零不进入数据库

php - 自动递增 id

android - facebook 帐户工具包 - 返回错误 "We' 抱歉,出了点问题。”在 android 中

java - Robolectric + Mockito - "Wanted but not invoked"