简体   繁体   中英

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

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 regular -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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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