简体   繁体   中英

How to post on friends wall using javascript/ php

I need to post something on my friends wall. i used a facebook friend selector. I implemented like this

//Execute the friend selector

 $(document).ready(function() {
  $(".shareFriends").fSelector({
    facebookInvite: false,
    onSubmit: function(ids){            
        publish(ids) // call the below function
    },

});
});


function publish(ids){

FB.ui(
  {
   method: 'feed',
   name: 'Name',
   caption: 'caption',
   to:ids,
   description: 'description ',
   link: 'link to my app?uref=<?php echo $_SESSION['uid']; ?>',
   picture: 'path to image'
  },
  function(response) {
    if (response && response.post_id) {
      alert('Post was published.');

    } else {
     alert('Post was faild');
    }
  }
);

}

when i run this i'm getting this error.

API Error Code: 100
API Error Description: Invalid parameter
Error Message: [100006588491260] does not resolve to a valid user ID

//this user id is working

I entered recipient id direct. this method works properly.

FB.ui(
  {
   method: 'feed',
   name: 'Name',
   caption: 'caption',
   to:100006588491260,
   description: 'description ',
   link: 'link to my app?uref=<?php echo $_SESSION['uid']; ?>',
   picture: 'path to image'
  },

How to fix this issue. and how can i send same post on multiple friends wall?

You can only specifiy one ID, not an array of IDs. There is one other possibility with the "send" dialog:

https://developers.facebook.com/docs/reference/dialogs/send/

...but according to the docs, you can only open it for one user too, the difference is that the user is able to add more people directly in the popup:

A user ID or username of a recipient. Once the dialog comes up, the sender can specify additional people, groups, and email addresses as recipients.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM