【问题标题】:posting message on facebook wall在 Facebook 墙上发布消息
【发布时间】:2013-02-11 10:09:55
【问题描述】:

我在 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",

      ));
  }

请任何人帮忙

【问题讨论】:

标签: php facebook facebook-wall


【解决方案1】:

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

【讨论】:

  • 当我禁用时,我收到错误 SSL 连接错误
  • 好吧,我现在只是猜测,但是如果你将$auth_url 协议更改为 https 会发生什么?
猜你喜欢
  • 1970-01-01
  • 2011-01-04
  • 1970-01-01
  • 2012-04-29
  • 2012-04-27
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多