2011-03-30 87 views
4

在朋友的墙上张贴消息,图API。 我有正在使用该应用程序的用户的publish_stream扩展权限。使用图形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); 
     } 

回答

7

这也许是做到这一点。 (未经测试,但我用我的应用程序类似的东西。)

$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', 
     )); 

} 

这是使用PHP API

+0

这不会工作了。看facebook博客以供参考。 https://developers.facebook.com/blog/post/2012/10/10/growing-quality-apps-with-open-graph/ – Underdog 2013-10-07 10:03:10

3

publish_stream权限只允许您在该特定用户墙上发布内容 - 不能张贴在他所有朋友的墙上。

想想这样 - 说你还没有授权应用程序在你的脸书墙上发布任何内容,但仅仅是因为你的一位朋友允许访问他的墙 - 它自动不会让应用程序访问发布在他所有朋友的墙。

编辑

拉胡尔,我想昨晚登录为自己和通过我的应用程序发布在我的一个朋友的墙上有一个消息令人惊讶它的工作。我错误的印象是你不能那样做。我很抱歉。

但我仍然无法弄清楚这一点。让我解释一下

 
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. 

我不知道是否有任何延迟,但我已经等了30分钟,但仍然不存在。但是当我以abc登录时,它会继续显示。

我希望你明白我想在这里表达。 我用同一块像您这样的代码 - 所以你尝试了上面的情况,看看是否会遇到类似

感谢

+0

冷静,但我怎么公布的用户朋友墙?是主要问题。 – 2011-04-01 20:55:55

+0

@rahul - 你不能张贴在用户朋友的墙上 - 就像我解释的那样 - 用户允许你在他的墙上发布 - 每个用户必须给予明确的许可 - 所以它不可能发布在墙上用户的朋友 - 这是据我所知 - 我今天会进一步挖掘,看看它是否可能 – Gublooo 2011-04-02 06:02:23

+1

@rahul - 我已经用我昨天做的小测试更新了我的答案。所以我收回我以前的评论,说它不可能。 – Gublooo 2011-04-03 06:30:23

0

Gubloo的答案是接近的东西。

张贴到朋友的墙壁完全是可能的,但有一点需要注意,说的朋友必须通过在某些点上“权限”对话框也不见了。这意味着,您的应用程序的用户将能够张贴到您的应用程序的其他用户的墙上。

我要给你的iPhone的代码,因为我不知道PHP和想象你会得到的要点。只需将“我”替换为您要发布的任何内容的UID,成为一个页面或朋友的个人资料即可。

[_facebook requestWithGraphPath:@"/me/feed" andParams:params andHttpMethod:@"POST" andDelegate:self];

实际上,我想知道这是否会给予用户发布的任何人谁使用的应用程序墙的能力,而不仅仅是他的朋友。

+1

_“说过的朋友在某个时候也必须经历'权限'对话。” - - 是什么给了你这个想法? – CBroe 2012-07-02 17:30:28

+0

我一定是错的。 – 2012-09-22 18:30:21

5

我只是做了一个小测试,让用户的权限,我确实可以通过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', 
    )); 
0

$ friends = $ facebook-> api('/ me/friends');

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', 
    )); 

} 以上为我工作代码tooooo 谢谢你的职位

相关问题