使用图形API在朋友的墙上发布

Ram*_*mar 4 php message facebook facebook-graph-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);
        }
Run Code Online (Sandbox Code Playgroud)

Maf*_*fia 6

这可能是这样做的方式..(未经测试,但我对我的应用程序使用类似的东西.)

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

}
Run Code Online (Sandbox Code Playgroud)

这是使用PHP API.


Bur*_*rgi 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',
      ));
Run Code Online (Sandbox Code Playgroud)