使用图形 API 在朋友的墙上发帖
在朋友墙上发布消息,图形 API。 我拥有正在使用该应用程序的用户的publish_stream扩展权限。
如果我想在墙上张贴某些内容,该代码就可以工作。
有没有什么方法可以在墙上张贴或向特定用户的所有朋友发送消息?
请帮忙谢谢!!
以下是代码,但它不起作用。
$friends = $facebook->api('/me/friends');
foreach($friends['data'] as $friend){
$friendsUserId = $friend['id'];
echo $friendsUserId . "</br>";
$result = $facebook->api('/$friendsUserId/feed', 'POST', array(
message' => 'Test Message' ));
print_r($result);
}
Posting a message on friend's wall, graph API.
i have the publish_stream extended permission of the user, who is using the application.
the code workds if i want to post sth on my wall.
is there any method to post on wall or send message to all the friends of a particular user??
please help thanks!!
following is the code, but it is not working.
$friends = $facebook->api('/me/friends');
foreach($friends['data'] as $friend){
$friendsUserId = $friend['id'];
echo $friendsUserId . "</br>";
$result = $facebook->api('/$friendsUserId/feed', 'POST', array(
message' => 'Test Message' ));
print_r($result);
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
这也许是实现它的方法。(未经测试,但我在我的应用程序中使用类似的东西。)
这是使用 PHP API。
This would perhaps be the way to do it.. (Untested, but I use something similar for my app.)
This is using the PHP API.
我只是做了一些测试,并且拥有用户的权限,我确实可以通过 php api 在用户的朋友墙上发布:
I just did a little testing, and having the permissions of the user, I could indeed post on the user's friends walls via the php api:
publish_stream 权限只允许您在该特定用户的墙上发布内容 - 您不能在他所有朋友的墙上发布内容。
以这种方式思考 - 假设您没有授权应用程序在您的 Facebook 墙上发布任何内容,但仅仅因为您的一个朋友授予了对他的墙的访问权限 - 它会自动授予该应用程序在他所有的墙上发布的权限朋友们。
编辑
拉胡尔,昨天晚上我尝试以自己的身份登录并通过我的应用程序在我的一位朋友的墙上发布消息,令人惊讶的是它有效。我的错误印象是你不能这样做。我很抱歉。
但我仍然无法弄清楚这一点。让我解释一下,
我不知道是否有任何延迟,但我已经等了 30 分钟,但仍然没有出现。但当我以 abc 身份登录时,它继续显示。
我希望你能理解我在这里想表达的意思。
我使用了与您相同的代码 - 所以您可以尝试上述场景,看看您是否遇到类似的情况
谢谢
The publish_stream permission only allows you to publish content on that particular users wall - you cannot post on the wall of all his friends.
Think about it this way - say you have not authorized an application to post anything on your facebook wall but just because one of your friends has given access to his wall - it automatically does not give the application access to publish on the wall of all his friends.
EDIT
Rahul, I tried yesterday night to login as myself and post a message on the wall of one of my friends through my app and surprisingly it worked. I was under the wrong impression that you could not do that. My apologies.
But I'm still not able to figure this out. Let me explain
I dont know if there is any kind of delay but I've waited 30 mins but still its not there. But it continues to show when I log in as abc.
I hope you understand what I'm trying to convey here.
I've used the same piece of code like yours - so can you try the above scenarios and see if you experience something similar
Thanks
Gubloo 的答案很接近。
发布到朋友的墙上是完全可能的,但需要注意的是,所述朋友也必须在某个时刻经历过“权限”对话。这意味着,您的应用程序的用户将能够在您的应用程序的其他用户的墙上发布内容。
我会给你 iPhone 代码,因为我不懂 php,并且想象你会明白要点。只需将“me”替换为您要发布的内容的 UID(页面或朋友的个人资料)即可。
[_facebook requestWithGraphPath:@"/me/feed"
andParams: 参数
andHttpMethod:@"POST"
andDelegate:self];
我实际上很好奇,这是否会让用户能够在任何使用该应用程序的人的墙上发帖,而不仅仅是他的朋友。
Gubloo's answer is close.
Posting to a friend's wall is completely possible, but with one caveat, said friend must have also gone through the 'Permissions' dialogue at some point. Meaning, users of your application will be able to post to the wall's of other users of your application.
I'm going to give you the iPhone code, because I don't know php and imagine you'll get the gist. Just replace 'me' with the UID of whatever you are trying to post to, be a page, or a Friend's profile.
[_facebook requestWithGraphPath:@"/me/feed"
andParams:params
andHttpMethod:@"POST"
andDelegate:self];
I'm actually curious to know if this would give the user the ability to post on the wall of anyone who uses the application, and not just his friends.
$friends = $facebook->api('/me/friends');
}
上面的代码对我也有用
感谢您的帖子
$friends = $facebook->api('/me/friends');
}
Above code work for me tooooo
Thanks for the post