duanji5746 2013-01-16 20:30
浏览 21
已采纳

Facebook发布为用户墙的页面

Okay I can't figure out what the problem here is... I am trying to post to a user wall as a page. I keep getting string(53) "(#200) The target user has not authorized this action" here is the complete code

       session_start();
      $config = array();
      $config['appId'] = 'xxxxxxxxx';
      $config['secret'] = 'xxxxxxxx';
      $config['fileUpload'] = false; // optional
      $facebook = new Facebook($config);

        $params = array(
          'scope' => 'user_birthday, user_likes, publish_actions, email, publish_stream, manage_pages',
          'redirect_uri' => 'xxxxxxxxxxxxx'
        );

        $loginUrl = $facebook->getLoginUrl($params);
        $logoutUrl = $facebook->getLogoutUrl();
        $user_id = $facebook->getUser();
    ?>
    <html>
      <head></head>
      <body>

      <?
        if($user_id) {
          try {
            echo 'Please <a href="' . $logoutUrl . '">logout.</a>';
            $user_profile = $facebook->api('/me','GET');
            echo "Name: " . $user_profile['name'];
            $access_token = $facebook->getAccessToken();
            $page_id = 'xxxxxxxxxx';
            $result = $facebook->api("/me/accounts");
            foreach($result["data"] as $page) {
                if($page["id"] == $page_id) {
                    $page_access_token = $page["access_token"];
                    break;
                }
            }
            if( !empty($page_access_token) ) {
                $args = array(
                    'access_token'  => $page_access_token,
                    'message'       => "Hello Billy!!"
                );
                $post_id = $facebook->api("/{$user_profile['id']}/feed","post",$args);

            } else {
            }

    //        $page = $facebook->api("/{$page_id}",'GET');


          } catch(FacebookApiException $e) {
            error_log($e->getType());
            error_log($e->getMessage());
            ?><pre><?var_dump($e->getMessage())?></pre><?
          }   
        } else {
    ///
          echo 'Please <a href="' . $loginUrl . '">login.</a>';

        }

      ?>

      </body>
    </html>
  • 写回答

1条回答 默认 最新

  • dongyuli4538 2013-01-16 21:10
    关注

    Just to confirm, you're trying to post to a user's profile or timeline, and have the post appear with a Page as the sender?

    That's not possible and never has been. The API simply doesn't support it.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 前端echarts坐标轴问题
  • ¥15 CMFCPropertyPage
  • ¥15 ad5933的I2C
  • ¥15 请问RTX4060的笔记本电脑可以训练yolov5模型吗?
  • ¥15 数学建模求思路及代码
  • ¥50 silvaco GaN HEMT有栅极场板的击穿电压仿真问题
  • ¥15 谁会P4语言啊,我想请教一下
  • ¥15 这个怎么改成直流激励源给加热电阻提供5a电流呀
  • ¥50 求解vmware的网络模式问题 别拿AI回答
  • ¥24 EFS加密后,在同一台电脑解密出错,证书界面找不到对应指纹的证书,未备份证书,求在原电脑解密的方法,可行即采纳