Send Gifts from PHP Facebook App?
I need to be able to let users send each other gifts from my facebook app. I know how I'm going to store the gift data in the database, but I'm not sure how the user cans elect friends to send the gift to.
First I tried this:
<fb:fbml>
<fb:request-form
action="index.php"
method="POST"
invite="true"
type="YOUR APP NAME"
content="Your text goes here. <?php echo htmlentities("<fb:req-choice url=\"YOUR CANVAS URL\" label=\"Authorize My Application\"") ?>" >
<fb:multi-friend-selector showborder="false" actiontext="Invite your friends to use YOUR APP NAME.">
</fb:request-form>
</fb:fbml>
And used :
$users = $_REQUEST['ids'];
to get the list of selected users on the POSTed page, but the code above also sends the request right away. I need 开发者_如何学JAVAto be able to generate links based on the users selected, then send the request.
Any help on this would be greatly appreciated!
There are currently 2 strategies to send gifts via facebook.
Invite
With invite you usually use the facebook widgets to select users and send an invite (or request). The invite contains a custom url to your canvas landing page, which should ask the user to accept the gift. Put the target url into the url attribute of fb:req-choice.
Wallpost
With wallposts you can either use the facebook widgets or the graph api to post something on the users wall. For the latter the user needs to grant the publish_stream permission to your application. The wallpost are visible to all the friends of the user and contain - similar to invite - a url to your landing page. (Note that wallposts are not limited. Actively played zynga games usually render your wall useless.)
For selective user triggered wallposts i'd recommend the JS api.
I've never done this, but I think it can be less straight-forward then it seems. I suggest you have a look at some other applications that do gifting, maybe you can find something from there. f.e. I think FarmVille uses a seperate application for gifting. anyone who accepts the request for that seperate application receives the gift, and then gets redirected to the main game.
精彩评论