开发者

Publish on users facebook wall

开发者 https://www.devze.com 2023-02-24 12:29 出处:网络
The users of th开发者_运维知识库e website I\'m building should be able to publish a title, a picture and a link on their facebook wall.

The users of th开发者_运维知识库e website I'm building should be able to publish a title, a picture and a link on their facebook wall.

I found many questions on the subject, but no decent answer...


The easiest way I've found is to use the JavaScript SDK: http://developers.facebook.com/docs/reference/javascript/

http://developers.facebook.com/docs/reference/javascript/FB.ui/

Load it up:

<div id="fb-root"></div>
<script>
  window.fbAsyncInit = function() {
  FB.init({appId: 'your app id', status: true, cookie: true,
         xfbml: true});
}; 
(function() {
    var e = document.createElement('script'); e.async = true;
    e.src = document.location.protocol +
      '//connect.facebook.net/en_US/all.js';
    document.getElementById('fb-root').appendChild(e);
}());
</script>

Use the FB.ui method in your JavaScript file (fill in your data accordingly):

FB.ui(
   {
     method: 'feed',
     name: 'Facebook Dialogs',
     link: 'http://developers.facebook.com/docs/reference/dialogs/',
     picture: 'http://fbrell.com/f8.jpg',
     caption: 'Reference Documentation',
     description: 'Dialogs provide a simple, consistent interface for applications to interface with users.',
     message: 'Facebook Dialogs are easy!'
   },
   function(response) {
     if (response && response.post_id) {
       alert('Post was published.');
     } else {
       alert('Post was not published.');
     }
   }
);
0

精彩评论

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