Ishan Jain
Ishan Jain

Reputation: 8171

how to upload image with feed using FB.api method

we are using Fb API for post feed on facebook.

my code is -

            if (response.authResponse) {                   
                var data =
                {
                    name: "link to apply",
                    picture: 'http://www.hrgp.biz/Uploads/CompanyForTesting_499/NotesReminders/2608chemtec-logo.jpg',
                    link: "http://www.hrgp.biz/bc0efdb3-f1a7-4d81-9635-d1418e808b6d.aspx",  // Go here if user click the picture
                    description: "thank you"                        
                }
                FB.api('me/feed', 'post', data, function (response) {
                    if (!response || response.error) {
                        alert(JSON.stringify(response.error));
                    } else {
                        //alert('Post ID: ' + response.id);
                        alert('feed posted successfully.');
                    }
                });                   
            }
        }, { scope: 'email,user_likes,publish_actions,publish_stream,read_stream,photo_upload' });

This code Works but I’m having issues with the picture. It doesn’t show up in the post.

how can i resolve this issue? or please tell me if any problem into my code.

thank you..!!!

Upvotes: 3

Views: 3373

Answers (2)

Akshat Goel
Akshat Goel

Reputation: 786

FB.api('me/feed', 'post', { message: body,
                            picture :'PICTURE_URL',
                            description : "DESCRIPTION"
                            }
                    , function (res) {
    if(!res || res.error) {
        console.log(!res ? 'error occurred' : res.error);
        return;
    }
    console.log('Post Id: ' + res.id);

for more options check - https://developers.facebook.com/docs/graph-api/reference/v2.0/user/feed

Upvotes: 0

林果皞
林果皞

Reputation: 7793

Please refer to What is the minimum width and height Of Facebook Open Graph Images?.

The ratio of both height divided by width and width divided by height (w/h, h/w) cannot exceed 3.0.

Your photo, http://www.hrgp.biz/Uploads/CompanyForTesting_499/NotesReminders/2608chemtec-logo.jpg, 250/65 = 3.84615384615 obviously exceed the maximum ratio:

enter image description here

Upvotes: 1

Related Questions