繁体   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