Php 在朋友上发帖';使用graph API创建s墙

Php 在朋友上发帖';使用graph API创建s墙,php,facebook,facebook-graph-api,message,Php,Facebook,Facebook Graph Api,Message,在朋友的墙上发布消息,graph API。 我拥有使用应用程序的用户的发布流扩展权限 如果我想把东西贴在墙上,代码就起作用了 是否有任何方法可以在墙上张贴或向特定用户的所有朋友发送消息 请帮忙,谢谢 下面是代码,但它不起作用 $friends = $facebook->api('/me/friends'); foreach($friends['data'] as $friend){ $friendsUserId = $friend['id'];

在朋友的墙上发布消息,graph API。 我拥有使用应用程序的用户的发布流扩展权限

如果我想把东西贴在墙上,代码就起作用了

是否有任何方法可以在墙上张贴或向特定用户的所有朋友发送消息

请帮忙,谢谢

下面是代码,但它不起作用

 $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);
        }
$friends=$facebook->api('/me/friends');
foreach($friends['data']作为$friends){
$friendsUserId=$friend['id'];
echo$friendsUserId。“
”; $result=$facebook->api('/$friendsUserId/feed',POST',数组( 消息“=>”测试消息“); 打印(结果); }
发布流权限只允许您在特定用户的墙上发布内容-您不能在他所有朋友的墙上发布内容

这样想吧——假设你没有授权一个应用程序在你的facebook墙上发布任何东西,但仅仅因为你的一个朋友已经允许你访问他的墙壁——它自动不会允许该应用程序在他所有朋友的墙上发布

编辑

拉胡尔,昨天晚上我试着以我自己的身份登录,并通过我的应用程序在我的一个朋友的墙上发布了一条消息,令人惊讶的是,它居然成功了。我误以为你不能那样做。我道歉

但我还是没能弄明白。让我解释一下

1) I have my real facebook lets call it abc and a test facebook account xyz which I've added as my friend to abc 2) I login into my app using my abc faceboook account and publish a message on the wall of my friend xyz 3) Now I login to facebook.com as abc and it shows on my news feed the message that I published on xyz's wall. When I click on xyz's profile - the message shows up on his wall too. So far so good 4) Now I log out of facebook.com as abc and log back in as xyz. But now I dont see the message that was posted through the app on the wall of xyz. 1) 我有一个真实的facebook账户叫abc,还有一个测试facebook账户xyz,我把它作为我的朋友加入了abc 2) 我使用我的abc faceboook帐户登录我的应用程序,并在我朋友xyz的墙上发布一条消息 3) 现在我以abc的身份登录facebook.com,它会在我的新闻提要上显示我在xyz的墙上发布的消息。当我点击xyz的个人资料时,信息也会显示在他的墙上。到现在为止,一直都还不错 4) 现在我以abc的身份从facebook.com注销,以xyz的身份重新登录。但现在我看不到通过应用程序在xyz墙上发布的消息。 我不知道是否有任何形式的延误,但我已经等了30分钟,但仍然没有。但当我以abc身份登录时,它会继续显示

我希望你能理解我想表达的意思。 我使用了与您相同的代码片段-因此您可以尝试上述场景,看看是否有类似的体验吗


谢谢

古布洛的回答很接近

张贴到朋友的墙上是完全可能的,但有一点需要注意,这位朋友一定在某个时候也经历了“权限”对话。也就是说,您的应用程序的用户将能够发布到您的应用程序的其他用户的墙上

我将给你iPhone代码,因为我不懂php,我想你会明白要点。只需将“我”替换为您试图发布到的任何内容、页面或朋友的个人资料的UID即可

[[u facebook requestWithGraphPath:@”/me/feed”
andParams:params
和httpmethod:@“POST”
和代表:自我]


实际上,我很想知道这是否会让用户能够在使用该应用程序的任何人的墙上发布,而不仅仅是他的朋友。

我只是做了一点测试,并且拥有用户的权限,我确实可以通过php api在用户的朋友墙上发布:

$facebook->api('/[FRIEND_ID]/feed', 'post', array(
          'message' => 'test message',
          'link' => 'http://google.com',
          'name' => 'test name',
          'caption' => 'test caption',
          'description' => 'test long description',
      ));

这也许是做这件事的方法。。(未经测试,但我在我的应用程序中使用了类似的东西。)

这是使用PHP API('/me/friends')

} 以上代码对我来说很有用
谢谢你的帖子

很酷,但是我如何在用户朋友的墙上发布呢??这是主要问题。@rahul-你不能在用户朋友的墙上发表文章-正如我所解释的-用户已经授予你在其墙上发表文章的权限-每个用户都必须给予明确的权限-因此你不可能在用户朋友的墙上发表文章-就我所知-我今天将进一步挖掘然后回去看看它是不是possible@rahul-我用昨天做的小测试更新了我的答案。所以我收回了我之前的评论,说这是不可能的。有一些垃圾邮件应用程序可以做到这一点,我是其中的一个受害者。有办法做到这一点。挖出来让我知道。“谢谢你的努力。”这位朋友说,他一定在某个时候也经历过“权限”对话。”–是什么让你产生了这样的想法?这已经不起作用了。请参阅facebook博客以获取参考。
$friends = $facebook->api('/me/friends');

    foreach($friends['data'] as $friend) {
        $facebook->api('/$friend['id']/feed', 'post', array(
                  'message' => 'just a test message',
                  'link' => 'http://site.com',
                  'name' => 'just a test name',
                  'caption' => 'just a test caption',
                  'description' => 'just a test description',
          ));

}
foreach($friends['data'] as $friend) {
    $facebook->api('/$friend['id']/feed', 'post', array(
              'message' => 'just a test message',
              'link' => 'sample link.com',
              'name' => 'just a test name',
              'caption' => 'just a test caption',
              'description' => 'just a test description',
      ));