-4

我尝试了许多使用 php sdk 发布用户墙的方法。但没有成功。任何人都知道成功发布到墙。请帮助我...此代码返回任何错误,但不会发布用户时间石灰。目前我正在使用这个php代码..

  require_once('src/facebook.php');

  $config = array(
'appId' => '#########',
'secret' => '#########################',
  );

  $facebook = new Facebook($config);
 $user_id = $facebook->getUser();
 echo $user_id;
$access_token = $facebook->getAccessToken();
 if($user_id!=0) 
 {


 try {$attachment =  array(
 'message' => "good Evening",
  'name' => "good Evening",
 'link' => "good Evening",
'description' => "good Evening",
'picture'=>"http://hotactresshotphotos.files.wordpress.com/2011/02/bhama_028.jpg",
'actions' => json_encode(array('name' => $action_name,'link' => $action_link))
      ); 

$result = $facebook->api('/'.$user_id.'/feed', 'post', $attachment);

} 

   catch(FacebookApiException $e) {

    $login_url = $facebook->getLoginUrl( array(
                   'scope' => 'publish_stream'
                   )); 
    echo 'Please <a href="' . $login_url . '">login.</a>';
    error_log($e->getType());
    error_log($e->getMessage());
  }   

  echo '<br /><a href="' . $facebook->getLogoutUrl() . '">logout</a>';
} else {


  $login_url = $facebook->getLoginUrl( array( 'scope' => 'publish_stream' ) );
  echo 'Please <a href="' . $login_url . '">login.</a>';

} 
4

1 回答 1

3

你到底得到了什么错误?顺便说一句,只要您拥有 publish_stream 权限,它对我有用:

$attachment =  array(
                 'access_token' => $access_token,
                 'message' => "$message",
                 'name' => "$name",
                 'description' => "$description",
                 'link' => "$link",
                 'picture' => "$pictureUrl",
                 'actions' => array('name'=>'Try it now', 'link' => "$appUrl")
               );

               try{
                  $post_id = $facebook->api("me/feed","POST",$attachment);
               }catch(Exception $e){
                  error_log($e->getMessage());
               }
于 2012-10-23T06:17:28.150 回答