簡體   English   中英

吸引大量Facebook用戶-發布到朋友牆

[英]Taking a Facebook array of users - post to friends wall

我有一系列的Facebook用戶,這些用戶是使用自定義Facebook Multi-Selector輸出的。

輸出是所選用戶的列表。

如何獲取這些ID號,然后使用Facebook API在其牆上張貼消息?

以下是我之前使用過的有效的PHP代碼段

$attachment =  array(
  'from' => $_SESSION['username'],
  'access_token' => $access_token,
  'message' => $message,
  'name' => $title,
  'link' => $url,
  'description' => $description,
  'caption' => $caption,
  'picture' => $img,
  'privacy' => json_encode(array('value' => 'FRIENDS_OF_FRIENDS'))
);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,'https://graph.facebook.com/'.$userid.'/feed');
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $attachment);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);  //to suppress the curl output 
$result = curl_exec($ch);
curl_close ($ch);

參考: Facebook Graph API發布

  1. 確保您具有為您的應用指定的有效訪問令牌。

  2. 向您的用戶請求“ publish_stream”權限。

編輯:

這是發布到用戶牆上的JavaScript方法

function fb_publish() {
     FB.ui(
       {
         method: 'stream.publish',
         message: 'Message here.',
         attachment: {
           name: 'Name here',
           caption: 'Caption here.',
           description: (
             'description here'
           ),
           href: 'url here'
         },
         action_links: [
           { text: 'Code', href: 'action url here' }
         ],
         user_prompt_message: 'Personal message here'
       },
       function(response) {
         if (response && response.post_id) {
           alert('Post was published.');
         } else {
           alert('Post was not published.');
         }
       }
    );  
}

暫無
暫無

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

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