More action links in single wallpost

南笙酒味 提交于 2019-12-09 13:42:19

问题


Is it possible to create wallpost with more than one action link?

My code works only with one action link. Wallpost with two action links is not sent to Facebook (no error message).

var publish = {
    method : 'feed',
    name : name,
    link : link,
    picture : picture,
    caption : caption,
    description : description,
    message : message,
    actions : [{
        name : 'Link 1',
        link : 'http://www.example.com'
        },{
        name : 'Link 2',
        link : 'http://www.example2.com'
        }]   
};

FB.api('/me/feed', 'POST', publish, function(response) {});

回答1:


I got a response from Facebook and you really can not add more than one action link.

Correct code for adding one link is:

var publish = {
    // ....
    actions : {
        name : 'Some Action Link!',
        link : 'http://www.example.com'
        }
};



回答2:


Yes.

According to http://developers.facebook.com/docs/reference/rest/stream.publish/, the action_links parameter is a "JSON-encoded array of action link objects, containing the link text and a hyperlink."

It looks like you're calling it actions, not action_links. Try this instead:

var publish = {
    method : 'feed',
    name : name,
    link : link,
    picture : picture,
    caption : caption,
    description : description,
    message : message,
    action_links : [{
        name : 'Link 1',
        link : 'http://www.example.com'
        },{
        name : 'Link 2',
        link : 'http://www.example2.com'
        }]   
};


来源:https://stackoverflow.com/questions/8275428/more-action-links-in-single-wallpost

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!