簡體   English   中英

使用Facebook API發布到朋友的牆

[英]Publish to a friend's wall using Facebook API

我知道我們可以這樣在朋友的牆上發布一些東西:

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

只需將$ user變量替換為朋友的用戶ID。

我只希望在朋友中選擇我想使用復選框寫的用戶個人資料。

例如,如果您要共享粉絲頁面,這已經可以實現。 您選擇將請求發送給的人。

在此先感謝您的幫助

您可以使用Facebook的Multi-Friend-Selector(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時,這是可能的。 請參閱如何使用Facebook ID向朋友發送Facebook消息中的答案

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM