0

我想从我们的网站在 facebook 墙上发布一条消息。首先我收到错误

Uncaught OAuthException: (#200),当试图在墙上发帖时

现在我没有收到错误,但代码不起作用。

$facebook = new Facebook(array(
  'appId' => APP_ID,
  'secret' => APP_SECRET,
  'cookie' => true,
  'req_perms' => 'email,read_stream,read_friendlists,publish_stream,offline_access,manage_pages',
));
$user = $facebook->getUser();
$token = $facebook->getAccessToken();
if ($user) {
  try {
    $user_profile = $facebook->api('/me');
  } catch (FacebookApiException $e) {
    error_log($e);
    $user = null;
  } 
}
if (!empty($user_profile )) {
  $username = $user_profile['name'];
  $uid = $user_profile['id'];
  try {
    $post=$facebook->api("/".$uid."/feed", "post", array(
      'access_token' => $token,
      'message' => 'test',
    ));
  } catch (FacebookApiException $e) {
    error_log($e);
    $user = null;
  }
}

但是没有消息来怎么办?创建应用程序时有什么问题吗?

4

1 回答 1

0

这是我的疯狂猜测,因为我们的评论问答不会很好地工作。

如果您使用一组权限授权您的应用程序,然后更改您的应用程序请求的权限(在应用程序管理页面),您现有的授权不会更新以包含新权限。您的应用仍可运行,但需要新权限的操作将失败。

您可以通过简单地从您的个人帐户应用设置页面中删除该应用并使用新权限重新批准该应用来测试这是否会导致您的错误。如果您的问题消失了,那么恭喜您。如果没有,您将需要做更多的侦探工作。您的代码似乎很好。

于 2013-02-09T08:53:43.590 回答