开发者

Facebook PHP Api cUrl auto post to page's wall (not profile wall)

I need to be able to post to the wall of my page, i have given offline_permissions and I got it to post to my profile wall but I need it to post to my pages wall.

Anyone know how to do this, where does my code need changing? thanks

<?php session_start();

$fb_page_id = xxxxxxxxxxxxxxxx;
$fb_access_token = 'xxxxxxxxx|xxxxxxxxxxxxxxxxxx-xxxxxxxx|xxxxxxxxxxxxxxxxxxxxxxx';

$url = 'https://graph.facebook.com/'.$fb_page_id.'/feed';

$attachment =  array(
'access_token' => $fb_access_token,
'message' => 'message text',
'name' => 'name text',
'link' 开发者_开发问答=> 'http://domain.com/',
'description' => 'Description Text',
'picture'=>'http://domain.com/logo.jpg',
 );

 // set the target url
 $ch = curl_init();
 curl_setopt($ch, CURLOPT_URL,$url);
 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
 curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
 curl_setopt($ch, CURLOPT_POST, true);
 curl_setopt($ch, CURLOPT_POSTFIELDS, $attachment);
 curl_setopt($ch, CURLOPT_HEADER,0);
 curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
 $go = curl_exec($ch);

 curl_close ($ch);

?>


$config = array(
    'appId' => 'YOUR_APP_ID',
    'secret' => 'YOUR_APP_SECRET',
    'allowSignedRequest' => false //optional but should be set to false for non-canvas apps
);

$facebook->api('/me/feed', 'POST',
    array(
      'link' => 'www.example.com',
      'message' => 'Posting with the PHP SDK!'
 ));

https://developers.facebook.com/docs/php/howto/postwithgraphapi/

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜