[英]Unable to retrieve Facebook Wall Posts
Using Facebook Graph API and my app credentials I am able to retrieve a valid token: 使用Facebook Graph API和我的应用程序凭证,我可以检索有效令牌:
171372936213670|xxxxxxxxxxxxxxxxxx-650901429|x_xxxxxxxxxxxxxxx-xxxxxxxx
The code I use to retrieve Wall Posts: 我用来检索Wall Post的代码:
function getFbWallPosts($user, $limit=5) {
$ci =& get_instance();
$token = $ci->facebook->getAccessToken();
$param = array(
'access_token' => $token,
'limit' => $limit,
);
$posts = $ci->facebook->api("$user/feed", 'GET', $param);
return $posts;
}
The function always returns an empty jSON result: 该函数始终返回空的jSON结果:
{"data":[]}
Also tested directly accessing Wall Posts using cURL: 还测试了使用cURL直接访问Wall Post的情况:
function fbrequest($url) {
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
curl_close($ch);
return $output;
}
...to no avail. ...无济于事。
EDIT: Also tried using file_get_contents but it also returns empty jSON: 编辑:也尝试使用file_get_contents,但它也返回空的jSON:
function fbrequest($url) {
$output = file_get_contents($url);
return $output;
}
Tried pasting the request string directly on my browser (without a user logged in to Facebook): 尝试将请求字符串直接粘贴到我的浏览器中(没有用户登录Facebook):
https://graph.facebook.com/AValidFacebookUsername/feed?access_token=171372936213670|xxxxxxxxxxxxxxxxxx-650901429|x_xxxxxxxxxxxxxxx-xxxxxxxx
...successfully returns a jSON string with all the posts ...成功返回所有帖子的jSON字符串
Any ideas guys? 有想法吗?
Try... 尝试...
function curl($url){
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
$content = curl_exec($curl);
curl_close($curl);
return $content;
}
If no luck, maybe Apache is not compiled with SSL support. 如果运气不好,也许Apache编译时没有SSL支持。
I just found out that there is nothing wrong with the codes I'm writing. 我刚刚发现我编写的代码没有错。 The problem is with how I interpreted the process and, eventually, the result.
问题在于我如何解释过程以及最终的结果。 There are pre-requisites on accessing other user's data on FB and in case of group pages, one of them is that the user requesting the data MUST BE A FAN OF THAT GROUP.
在FB上访问其他用户的数据具有先决条件,对于组页面,其中之一是请求数据的用户必须是该组的粉丝。
Silly me... 愚蠢的我...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.