1
votes

I'm attempting to use the Facebook Javascript SDK to post to an authenticated user's friend's wall. I get what appears to be a valid post ID in the response but the post does not appear on Facebook, and when I use the FB Graph API explorer to view the post, it simply returns false.

I'm using the FB login button with "publish_stream" permission for authentication and have a test FB app set up to get a valid App ID. I'm using the following code to post to the user's friend's wall:

FB.api('/[USER_ID]/feed', 'post', {
    message: 'Testing the Facebook JavaScript API',
    link: 'http://developers.facebook.com'
}, function(response) {
    if (!response || response.error) {
        console.log('Error occured');
    } else {
        console.log('Post ID: ' + response.id);
        console.dir(response);
    }
});

It works as expected when I replace [USER_ID] with 'me' - I can see the post on my FB timeline. However, when I use one of my friends' user IDs, I get a post ID response, but the post does not appear anywhere on their feed. Thoughts?

Here's my login button, too:

<fb:login-button show-faces="false" width="200" scope="publish_stream,publish_actions" perms="publish_stream"></fb:login-button>
4
Did you ask for the permissions to write on friend's wall?Enrico Susatyo
How do you explicitly ask for the friend's permission? I wouldn't think that you would need to do so, since as a user I can already make a post to any friend's wall outside of the SDK, and regarding the extended permission "publish_stream," the FB Permissions documentation says, "With this permission, you can publish content to a user's feed at any time." developers.facebook.com/docs/reference/api/permissionstravishigdon
What you can do outside the SDK without permission does not necessarily mean that you can do the same in the SDK. But in this case I think you do have the right permission if you have "publish_stream". What response did you get when you do that to your friend's wall?Enrico Susatyo
did you try different users? it might be possible for a user to adjust their privacy settings so apps can't do this.Gil Birman
The response I get is a postID that appears valid - not an error. But when I try to inspect the post in the the FB Graph API explorer, it simply returns false.travishigdon

4 Answers

2
votes

I had the same problem. I worked on it like crazy for 5 hours. And actually, I think there is no problem. The only thing is that the posts on other's walls can arrive few hours later.

If anyone has the same problem, at least wait for a few hours before completely changing your code and turning crazy.

0
votes

You can't post to a friend's wall

0
votes

I was able to resolve this issue by creating an entirely new FB App from scratch, after which point the above code worked, which led me to think the issue must be in the configuration of my previous Facebook app. The only major difference I found was in App > Settings > Basic > Website > Site URL, I had entered the domain for my app and not the full path to the app page itself. So, you can indeed dynamically publish a post to the authenticated user's friend's wall.

0
votes

here is with javascript sdk and facebbok c# 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.');
         }
       }
     );  
  }

and

var client = new FacebookClient("my_access_token");
dynamic parameters = new ExpandoObject();
parameters.message = "Check out this funny article";
parameters.link = "http://www.example.com/article.html";
parameters.picture = "http://www.example.com/article-thumbnail.jpg";
parameters.name = "Article Title";
parameters.caption = "Caption for the link";
parameters.description = "Longer description of the link";
parameters.actions = new {
    name = "View on Zombo",
    link = "http://www.zombo.com",
};
parameters.privacy = new {
    value = "ALL_FRIENDS",
};
parameters.targeting = new {
    countries = "US",
    regions = "6,53",
    locales = "6",
};
dynamic result = client.Post("me/feed", parameters);

and would you please mark it as answered if it helps :)