1

我在 facebook 上创建了一个应用程序。现在我想在 facebook 墙上发布消息。由于我是应用程序的开发人员,所以当我登录到我的 facebook 帐户时,消息就会出现在我的墙上,但是当我登录到另一个用户时,这个应用程序没有得到并且页面正在重定向到http://www.facebook.com/4oh4.php。我的代码如下

$facebook = new Facebook(array(

            'appId' => myAppId,
            'secret' => myAppSecret,
                'cookie' => true,
                'req_perms' => 'email,read_stream,read_friendlists,publish_stream,offline_access,manage_pages'

        ));
    $user = $facebook->getUser();
$app_id = myAppId;
        $canvas_page = "https://apps.facebook.com/apptestingas/";
        $auth_url = "http://www.facebook.com/dialog/oauth?client_id=" 
            . $app_id . "&redirect_uri=" . urlencode($canvas_page)."&scope=email,read_stream,read_friendlists,publish_stream,offline_access,manage_pages";
 if(isset($_REQUEST["signed_request"]))
     {
        $signed_request = $_REQUEST["signed_request"];
        list($encoded_sig, $payload) = explode('.', $signed_request, 2); 
        $data = json_decode(base64_decode(strtr($payload, '-_', '+/')), true);

     }
      if (empty($data["user_id"]))
     {
        echo("<script> top.location.href='" . $auth_url . "'</script>");

     }
     else 
     {
        $uid = $data["user_id"];

     } 
try {
    // Proceed knowing you have a logged in user who's authenticated.
 echo $token = $facebook->getAccessToken();
$user_profile = $facebook->api('/'.$uid.'',array (
'access_token' => $token)
);


  } catch (FacebookApiException $e) {
    error_log($e);
    $user = null;
  }
  if (!empty($user_profile )) {
        # User info ok? Let's print it (Here we will be adding the login and registering routines)

       echo  $username = $user_profile['name'];
    $uid = $user_profile['id'];
$facebook->api('/'.$uid.'/feed', 'post', array(
          'message' => "sdsgdg testingbbbb",

      ));
  }

请任何人帮助

4

1 回答 1

1

您的应用程序是否设置为沙盒模式?这可以在应用程序设置中控制。引用描述:“如果启用,只有应用程序开发人员才能使用应用程序”。

于 2013-02-11T10:15:41.087 回答