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 组策略中的计算机配置策略无法下发
  • ¥15 如何绘制动力学系统的相图
  • ¥15 对接wps接口实现获取元数据
  • ¥20 给自己本科IT专业毕业的妹m找个实习工作
  • ¥15 用友U8:向一个无法连接的网络尝试了一个套接字操作,如何解决?
  • ¥30 我的代码按理说完成了模型的搭建、训练、验证测试等工作(标签-网络|关键词-变化检测)
  • ¥50 mac mini外接显示器 画质字体模糊
  • ¥15 TLS1.2协议通信解密
  • ¥40 图书信息管理系统程序编写
  • ¥20 Qcustomplot缩小曲线形状问题