2012-02-28 60 views

回答

0

您必須對您的應用程序給相關權限(publish_stream,管理頁) 那麼你可以發佈到頁面的頁面

張貼到頁面,頁面,如果你有網頁的access_token可以是這樣的:

include_once ('src/facebook.php');/// include sdk 
    ////// config The sdk 
     @ $facebook = new Facebook(array(
     'appId' => 'XXXXXXX', 
     'secret' => 'XXXXXXXXXXXXXX', 
     )); 
    try{   
    $post=$facebook->api('PAGE_ID/feed/','POST',array(
    'message' => '$message', 
    'link'=>'http://apps.facebook.com/xxxxxxx/link.php?link=', 
    'picture'=> 'XXXXXXXXXX', 
    'name'=>'XXXXXX', 
    'description'=>'yes', 
    'access_token'=>'PAGE ACCESS TOKEN' 

    )); 
    } 
    catch(FacebookApiException $e) { 
    echo $e->getType(); 
    echo '<br />'; 
    echo $e->getMessage(); 
    } 

&,如果你沒有訪問令牌(你又需要上述權限),我認爲這可以幫助你

include_once ('src/facebook.php');/// include sdk 
    ////// config The sdk 
     @ $facebook = new Facebook(array(
     'appId' => 'XXXXXXX', 
     'secret' => 'XXXXXXXXXXXXXX', 
     )); 
$facebook->destroySession(); 
    try{   
    $post=$facebook->api('PAGE ID/feed/','POST',array(
    'message' => '$message', 
    'link'=>'http://apps.facebook.com/xxxxxxx/link.php?link=', 
    'picture'=> 'XXXXXXXXXX', 
    'name'=>'XXXXXX', 
    'description'=>'yes', 

    )); 
    } 
    catch(FacebookApiException $e) { 
    echo $e->getType(); 
    echo '<br />'; 
    echo $e->getMessage(); 
    } 

要了解如何獲取頁面的access_token,請檢查此鏈接: https://developers.facebook.com/tools/explorer/?method=GET&path=me%2Faccounts

相關問題