【问题标题】:simple facebook graph api call not working on live server but working on localhost简单的 facebook graph api 调用不在实时服务器上工作,但在 localhost 上工作
【发布时间】:2014-11-02 13:54:58
【问题描述】:

我正在尝试使用 facebook graph api 调用获取我的网站链接的 facebook 共享数量,为此我编写了以下代码:

  $url = "http://graph.facebook.com/http://www.example.com/";
  $content = file_get_contents($url);
  $json = json_decode($content, true);
  if (isset($json["shares"]) && $json["shares"] >= 1) {
     echo "Thanks for sharing";
  } else {
     echo "sorry, you have not yet shared my link.";
  }

上面的代码在我的本地主机上运行完美,但是当我尝试相同的代码时,它总是打印我sorry, you have not yet shared my link,即使我在 facebook 上分享它。

请帮忙,我需要做的更多..以便它也可以在实时服务器上运行.. 提前致谢

【问题讨论】:

    标签: php facebook facebook-graph-api file-get-contents


    【解决方案1】:

    经过大量搜索后,我知道我的服务器没有allow_url_fopen = On,所以我编辑了我的php.ini 文件..现在它运行完美......

    file_get_contents 方法需要allow_url_fopen = On ....

    我已经发布了这个答案,以便其他寻找这个的人.. 可以得到帮助..

    感谢每一位看过我问题的人..

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-11-11
      • 1970-01-01
      • 1970-01-01
      • 2020-12-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多