且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在Facebook中使用API​​在PHP中发布墙壁?

更新时间:2022-10-23 13:01:02

请确保您拥有Facebook SDK
https://github.com/facebook/php-sdk



启动Facebook API

  $ facebook = new Facebook(array(
'appId'=> YOUR_APP_ID ,
'secret'=> YOU_APP_SECRET,
'cookie'=> true,
));

确保您的用户具有publish_stream扩展权限
然后调用Facebook图表Feed:

  $ facebook-> api(/ $ user / feed,'post',array b $ b'message'=>
'link'=>'http://mywebsite.com',
'picture'=>'http:// mywebsite。 com / picture.jpg',
'name'=>'MyWebSite',
'description'=>'MyWebSite是我的网站'

) ;


I want to post score in wall in facebook using facebook API.

Make sure you have the Facebook SDK https://github.com/facebook/php-sdk

Initiate Facebook API

$facebook = new Facebook(array(
  'appId'  => YOUR_APP_ID,
  'secret' => YOU_APP_SECRET,
  'cookie' => true,
));

Make sure your user has the "publish_stream" extended permission then make a call to the facebook graph feed:

            $facebook->api("/$user/feed", 'post', array(
                'message' => "Hi",
                'link'    => 'http://mywebsite.com',
                'picture' => 'http://mywebsite.com/picture.jpg',
                'name'    => 'MyWebSite',
                'description'=> 'MyWebSite is a website for me!'
                )
            );