2012-02-28 62 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

相关问题