我有阅读Feed工作并取回我应该做的一切,它看起来像下面列出的数组:
我的问题是我想要检索单个邮件。我试过了:
// what I think should work - fails
$msgData = $facebook->api("/$fb_id/posts/$msgToken", 'GET', $parameters);
// link in msg (below) but fb gives "unknown browser" error message
$msgData = file_get_contents("http://www.facebook.com/$fb_id/posts/$msgToken");
// as per fb docs but this fails too...
$msgData = file_get_contents("https://graph.facebook.com/$msgToken");
那么,当您知道消息ID时,获取一条消息的真正方法是什么?
[0] => Array
(
[id] => 100002222222222_209088888888888
[from] => Array
(
[name] => My dog
[id] => 100002222222222
)
[message] => this is a test msg...
[picture] => http://platform.ak.fbcdn.net/www/app_full_proxy.php?app=999999999999999...
[link] => http://www.domain.com/
[name] => Application Name
[caption] => Caption of for this post
[description] => A description of this post
[icon] => http://www.facebook.com/images/icons/default_app_icon.gif
[actions] => Array
(
[0] => Array
(
[name] => Comment
[link] => http://www.facebook.com/100002222222222/posts/209088888888888
)
[1] => Array
(
[name] => Like
[link] => http://www.facebook.com/100002222222222/posts/209088888888888
)
)
[privacy] => Array
(
[description] => Friends
[value] => ALL_FRIENDS
[allow] => 0
[deny] => 0
)
)
答案 0 :(得分:1)
您可以通过帖子ID访问单个帖子,该帖子在您提供的示例中为100002222222222_209088888888888
。 (帖子ID为"{$user_id}_${message_id}"
)
要这样,您还需要有效access_token
。如果您使用Facebook PHP-SDK,它将使用登录用户access_token
(如果您登录到Facebook并且用户FB.login
或Facebook::getLoginUrl
)
$post_id = '100002222222222_209088888888888';
$msgData = $facebook->api("/{$post_id}");
否则你需要手动提供一个:
$post_id = '100002222222222_209088888888888';
$access_token = "APPLICATION_OR_USER_ACCESS_TOKEN";
// Using Facebook PHP-SDK
$parameters = array('access_token'=>$access_token);
$msgData = $facebook->api("/{$post_id}", 'GET', $parameters);
// OR
// Using file_get_contents
$url = "https://graph.facebook.com/{$post_id}?access_token={$access_token}";
$msgData = file_get_contents($url);