简体   繁体   English

带有属性的Facebook javascript SDK发布

[英]Facebook javascript SDK post with properties

Using a "Poll" app on Facebook, it would post something like this to my facebook Page (Kid Task): 使用Facebook上的“投票”应用程序,它会将类似这样的内容发布到我的Facebook页面(孩子任务): 在此处输入图片说明

How can I do this using Facebook javascript SDK? 如何使用Facebook javascript SDK执行此操作? As best as I can tell, this allows it https://developers.facebook.com/docs/guides/attachments/ but this says "for REST API" and that is deprecated right? 据我所知,这允许它https://developers.facebook.com/docs/guides/attachments/,但是上面写着“ for REST API”,那不赞成使用吗?

Code i've tried: 我尝试过的代码:

        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>';
            }
        }
    );

This posts without errors, but the properties are ignored. 这篇文章没有错误,但属性被忽略。

Figured it out finally, although i'm not sure what it was exactly. 终于弄清楚了,尽管我不确定它到底是什么。 My guess is, I was trying to post as a text post and not a link post. 我的猜测是,我试图将其发布为文本发布而不是链接发布。

    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