簡體   English   中英

Facebook PHP Api cUrl自動發布到頁面的牆(不是個人資料牆)

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

我需要能夠發布到頁面的牆上,我已經提供了offline_permissions,並且可以將其發布到我的個人資料牆上,但是我需要將其發布到我的頁面牆上。

任何人都知道該怎么做,我的代碼需要在哪里更改? 謝謝

<?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/

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM