繁体   English   中英

带有属性的Facebook javascript SDK发布

[英]Facebook javascript SDK post with properties

使用Facebook上的“投票”应用程序,它会将类似这样的内容发布到我的Facebook页面(孩子任务): 在此处输入图片说明

如何使用Facebook javascript SDK执行此操作? 据我所知,这允许它https://developers.facebook.com/docs/guides/attachments/,但是上面写着“ for REST API”,那不赞成使用吗?

我尝试过的代码:

        FB.api(
        'https://graph.facebook.com/kidtask/feed/',
        'post',
        {
            message: 'test question',
            actions: { name: 'Vote Now', link: 'http://test.com' },
            properties: { text: "test answer 1", href: "http://test.com" }
        },
        function(response) {
            if (!response) {
                alert('Error occurred.');
            } else if (response.error) {
                document.getElementById('result').innerHTML =
                    'Error: ' + response.error.message;
            } else {
                document.getElementById('result').innerHTML =
                    '<a href=\"https://www.facebook.com/kidtask/' +
                        response.id + '\">' +
                        'Story created.  ID is ' +
                        response.id + '</a>';
            }
        }
    );

这篇文章没有错误,但属性被忽略。

终于弄清楚了,尽管我不确定它到底是什么。 我的猜测是,我试图将其发布为文本发布而不是链接发布。

    FB.api(
        '/kidtask/feed/',
        'post',
        {
            name: 'whatever',
            link: 'http://url',
            actions: { name: 'Vote Now', link: 'http://url' },
            description:"\u003Cbr/\u003E",
            picture:"http://imageurl",
            caption:"\u003Cbr/\u003E",
            properties: [{"text":"test 1","href":"http://url"},{"text":"test 2","href":"http://url"},{"text":"test 3","href":"http://url"}]
        },

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM