Problem creating a post with object_id property using the JavaScript SDK and the graph api
After uploading a photo to an album that was created for my app, i want to create a post with that photo by using its id as a value of object_id. The photo gets uploaded, the post gets created, but there is no sign of the photo within the post. I have permissions for publish_steam and read_stream. Here is the code i´m using:
var params = {};
params['url'] = "http://some.url/image.jpg";
params['message'] = "some message entered by user";
FB.api('/me/photos', 'post', params, function(response){
if(!response){
console.log('no response after photos post');
}
else if(response.error){
console.log('response error');
}
else{
开发者_运维问答 var photo_id = response.id;
console.log('response ok after post');
FB.api('/me/feed/','post',
{
name: 'App-Name',
link: 'http://url_to_my_app_on_facebook'
caption: 'caption_for_my_app',
description: 'description_for_my_app'
message: 'some message entered by user',
object_id: parseInt(photo_id),
},
function(response) {
if (!response) {
console.log('no response after feed post');
} else {
console.log('post was created');
}
}
);
}
});
This should work, right? Maybe you guys can give me heads up where i went wrong...
Kaffeedraft
Your app will need user_photos permissions if you do not already have, you will also need to use a user access token.
- Refer to http://developers.facebook.com/blog/post/526/
- Refer to https://developers.facebook.com/tools/explorer/?method=GET&path=me%2Falbums to test scope for access.
- Refer to https://developers.facebook.com/docs/reference/api/user/#connections for permission need for connections.
精彩评论