【问题标题】:Facebook Graph API and FQL gives error in PHP [closed]Facebook Graph API和FQL在PHP中给出错误[关闭]
【发布时间】:2012-06-12 15:55:46
【问题描述】:

我正在尝试使用图形 api 运行 FQL。

$graph_url = "https://graph.facebook.com/fql?q=".$fql."&access_token=". $access_token;

$output = json_decode(file_get_contents($graph_url));

var_dump($output);

这会报错

[function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request

如果我将$graph_url 的内容复制并粘贴到浏览器中,我会得到预期的结果。所以,我确定我的 access_token 和 fql 查询是正确的。

另外,如果我尝试通过

  $graph_url = "https://graph.facebook.com/me/?access_token=". $access_token;

  $output = json_decode(file_get_contents($graph_url));

  var_dump($output);

我没有收到任何错误,而是预期的结果。我不确定,我的 fql 查询中缺少什么。

【问题讨论】:

  • $fql的内容是什么?

标签: php facebook-graph-api facebook-fql facebook-php-sdk


【解决方案1】:

我能做的最好的选择是 urlencode 问题。

试试这个,

$graph_url = "https://graph.facebook.com/fql?q=".urlencode($fql)."&access_token=". $access_token;

【讨论】:

  • 成功了!!!谢谢Subir :)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2015-03-19
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多