簡體   English   中英

在Facebook牆上發布消息

[英]posting message on facebook wall

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

      ));
  }

請任何人幫忙

您的應用程序是否設置為“沙盒模式”? 這可以在應用設置中控制。 引用描述:“如果啟用,則只有應用程序開發人員才能使用應用程序”。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM