FACEBOOK JS SDK :: how to post an image on the wall

I am trying to post a picture on the wall of my facebook users when they hit botton

I use the javascript SDK, but I have a problem, the image looks like a link in the wall ... but this is not what I want ... I want to place the image ... just like when you put a link to the image in the text box status and refers to the image

any help?

FB.ui(
           {
             method: 'stream.publish',
             message: 'test',
             attachment :{ 
                    'name': 'i\'m bursting with joy', 
                    'href': ' http://bit.ly/187gO1', 
                    'caption': '{*actor*} rated the lolcat 5 stars', 
                    'description': 'a funny looking cat', 
                    'properties': { 
                        'category': { 'text': 'humor', 'href': 'http://bit.ly/KYbaN'}, 
                        'ratings': '5 stars' 
                    }, 
                    'media': [{ 
                            'type': 'image', 
                            'src': 'http://icanhascheezburger.files.wordpress.com/2009/03/funny-pictures-your-cat-is-bursting-with-joy1.jpg', 
                            'href': 'http://bit.ly/187gO1'}] 
                        },
             user_message_prompt: 'Share your thoughts about Connect'
           },
           function(response) {
             if (response && response.post_id) {
               alert('Post was published.');
             } else {
               alert('Post was not published.');
             }
           }
+5
source share
2 answers

Try the FB.api()method:

var wallPost = {
    message : "testing...",
    picture: "http://url/to/pic.jpg"
};
FB.api('/me/feed', 'post', wallPost , function(response) {
  if (!response || response.error) {
    alert('Error occured');
  } else {
    alert('Post ID: ' + response);
  }
});

You can get a list of supported post post options here (see "Publishing").

+13
source

POST FB.api('/me/photos',...) FB.api('/me/feed',...), .

:

FB.login(function(response) {
    if (response.authResponse) {
        var access_token =   FB.getAuthResponse()['accessToken'];
        FB.api('/me/photos?access_token='+access_token, 'post', { url: IMAGE_SRC, access_token: access_token }, function(response) {
            if (!response || response.error) {
                //alert('Error occured: ' + JSON.stringify(response.error));
            } else {
                //alert('Post ID: ' + response);
            }
        });
    } else {
        //console.log('User cancelled login or did not fully authorize.');
    }
}, {scope: 'publish_stream'});

: facebook "/me".

"/"+friends_user_id+"/photos" ....
+12

All Articles