开发者

How to post on a facebook application user's facebook feed?

开发者 https://www.devze.com 2023-03-12 04:36 出处:网络
I have made a snake game using javascript and HTML5 Canvas element. It can be found at apps.facebook.com/snaqe_game. I have attained permissions and authorized the app for publish_feed or something us

I have made a snake game using javascript and HTML5 Canvas element. It can be found at apps.facebook.com/snaqe_game. I have attained permissions and authorized the app for publish_feed or something using the Facebook Developer Documentation but the problem I am facing is while posting the player's score on his wall. Following the documentation given by FB, you get a Dialog that asks the user before publishing and he can edit the Post. In a game, if I want to post the player's score, I cannot let him edit his petty 100 point score to a 100,000 point score. I have seen many games made on facebook that let the application post the Score of the Player by just a press of a button.

  • I do not have the PHP SDK
  • I don't know about cURL, so if you give a PHP example with cURL then please explain about it.
  • I'd really appreciate PHP code

Please See: apps.facebook.com/mg-copter NOTE: If you play the game on facebook, when you die you will be sent to a page submit开发者_如何学Go.php which does not exist. You must refresh the whole page to replay.


Using the Javascript SDK you can do something like:

var data = {
    method: 'stream.publish',
    display: 'iframe',
    message: 'Message Editable By User',
    attachment: {
        name: 'Title Not Editable By User',
        caption: 'Caption Not Editable By User',
        href: 'http://Link.To.Your.App'
    },
    action_links: [{
        text: 'Beat Me !',
        href: 'http://Link.To.Your.App' 
    }]
}
FB.ui(data);

You can play with the parameters until you get what you look for, but AFAIK you should not post to user's wall a message they can't edit or see.

Users will see a dialog with a predefined message they can edit (message attribute) and another part they cannot edit (attachment attribute).

0

精彩评论

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

关注公众号