使用Facebook API发布到朋友的墙上

时间:2012-09-11 15:20:50

标签: php facebook facebook-graph-api

我知道我们可以在朋友的墙上发布一些东西:

$publishStream = $facebook->api("/$user/feed", 'post', array(
     'message' => "Your Message", 
     'link'    => 'http://example.com',
     'picture' => '',
     'name'    => 'App Name',
     'description'=> 'App description'
));

只需将$ user变量替换为朋友的用户ID即可。

我希望只是在我的朋友中选择我想用复选框写的用户档案。

如果您想共享粉丝页面,这已经成为可能了。您可以选择发送请求的人员。

提前感谢您的帮助

1 个答案:

答案 0 :(得分:1)

您可以使用Facebook的多朋友选择器(MFS)https://developers.facebook.com/docs/guides/games/custom-muti-friend-selector/

从Multi-Friend-Selector文档中获取的编辑示例

function renderMFS() {
 // First get the list of friends for this user with the Graph API
 FB.api('/me/friends', function(response) {
   var container = document.getElementById('mfs');
   var mfsForm = document.createElement('form');
   mfsForm.id = 'mfsForm';

   // Iterate through the array of friends object and create a checkbox for each one.
   for(var i = 0; i < Math.min(response.data.length, 10); i++) {
     var friendItem = document.createElement('div');
     friendItem.id = 'friend_' + response.data[i].id;
     friendItem.innerHTML = '<input type="checkbox" name="friends" value="'
       + response.data[i].id
       + '" />' + response.data[i].name;
       mfsForm.appendChild(friendItem);
     }
     container.appendChild(mfsForm);

     // Extract selected friends' Facebook ID from value property of checked checkboxes

     // Do a for loop to send notification (refer to the link posted below) and publish post to each user's wall
   });
 }
  

是否可以在消息发送之前发送通知   写在墙上?

是的,有了Facebook ID就可以了。请参阅How to send Facebook message to friend using Facebook ID?

中的答案
相关问题