开发者

Facebook Graph API: How to add vote links to a wall post?

开发者 https://www.devze.com 2023-02-02 13:35 出处:网络
I am building a Facebook app with voting included. With it I want to send a message to the user\'s wall including some text and two or more links.

I am building a Facebook app with voting included. With it I want to send a message to the user's wall including some text and two or more links.

I also want to control the link text so that I can get links like "Yes" and "No".

The first thing I tried was posting regula开发者_如何学运维r -tags, but (no surprise) that didn't work. I have seen other apps do this though. Are there any special tags that allow links?

Thank you.


I'll assume that you're using the Graph API and already have publish a post working.

I think the properties property might be what you are looking for (it is left out of the new API reference but is described here). This allows links although they might not be formatted quite how you want. Example:

$data = array (
           'name'       => ...,
           'link'       => ...,
           'properties' => array (
                              'Yes' => array  (
                                        'text' => 'Vote',
                                        'href' => 'http://www.example.com?vote=yes'
                                       ),
                              'No' => array  (
                                        'text' => 'Vote',
                                        'href' => 'http://www.example.com?vote=no'
                                       )
                           ),
         ); //And whatever other properties you want
$facebook->api('/uid/feed', 'POST', $data);

The properties will appear after beneath description in the post and come out like the following:

Yes: Vote

0

精彩评论

暂无评论...
验证码 换一张
取 消