I'm trying to make a post with an Action. I already know how to make a post to the wall. My problem is adding the action to the post. I have se开发者_StackOverflow中文版arched on internet, but I can't seem to find the Action in a js /ID/feed post.
Image 1 - No action
Image 2 - Action - Vote on pictures
The action is the "Vote on photos" link under the post.
I have tried many things like:
var action = {
name: 'Vote on photos',
link: link
}
var attachment = {
name: message,
caption: caption,
link:link,
picture:pixUIurl,
action: Array()
}
attachment.action.push(action);
FB.api('/'+id+'/feed', 'post', attachment, function(response) {
if (!response || response.error) {
//alert('Error occured');
} else {
//alert('Post ID: ' + response.id);
}
});
and
var action = {
name: 'Vote on photos',
link: link
}
var attachment = {
name: message,
caption: caption,
link:link,
picture:pixUIurl,
action: function (){
0:action
}
}
FB.api('/'+id+'/feed', 'post', attachment, function(response) {
if (!response || response.error) {
//alert('Error occured');
} else {
//alert('Post ID: ' + response.id);
}
});
But I can't get the action working. Does someone know how to post with an action from js?
Tank you.
For help, the documentation has http://developers.facebook.com/docs/reference/api/post/.
Also, in the php sdk you can add an action like:
$attachment = array(
'name' => $message,
'caption' => $caption,
'link' => $link,
'picture' => $picture1,
'actions' => array(
array(
'name'=>'Vote on photos',
'link' => _CANVAS_PAGE
)
)
);
$result = $facebook->api('/user_id/feed/', 'post', $parameters );
Like that :
var attachment = {
name: message,
caption: caption,
link:link,
picture:pixUIurl,
actions: [{
name: "Vote on photos",
link: "_CANVAS_PAGE"}]
}
You have some examples in the JavaScript Test Console
精彩评论