使用Facebook Graph只需使用javascript发布一条墙消息

Gly*_*ine 40 javascript facebook facebook-graph-api

在Facebook上,如何在用户的墙上发布消息"我在对象游戏上得到8/10"然后是一个URL?

我真的不想使用完整的API,因为我不想处理用户登录的详细信息.我不介意Facebook是否需要进行身份验证然后发布消息.

是否可以使用新的Graph API和JavaScript?

Sou*_*sou 58

注意4/16/2011: stream.publish似乎已被弃用,有一种新的方法可以做到这一点:http://developers.facebook.com/docs/reference/dialogs/feed/

你可以使用这样的东西发布到墙上,用户需要在发送之前进行确认.不要忘记您需要使用FB.init并包含JS SDK链接.

 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.');
         }
       }
     );  
  }
Run Code Online (Sandbox Code Playgroud)

  • 我从我的一个工作代码中复制了它.功能测试:) (4认同)
  • F*cking爱你们.我今晚要试一试. (2认同)

Neh*_*hal 12

墙上的帖子将显示一个对话框,用于在墙上共享信息.但我想在用户的墙上静静地发布消息,假设用户已经给出了"Post on wall"权限.

FB.api('/me/feed', 'post', {
      message:'my_message',
      link:YOUR_SITE_URL,
      picture:picture_url
      name: 'Post name',
      description: 'description'
 },function(data) {
      console.log(data);
 });
Run Code Online (Sandbox Code Playgroud)