无法阅读或发布到朋友墙(新闻Feed)

时间:2012-05-23 04:54:51

标签: php facebook facebook-apps

我一直在尝试阅读朋友新闻Feed以检查我的消息是否存在(如果消息可见,隐藏或删除无关紧要),如果消息在那里,则不发布新消息。如果不是那么发布消息。代码在下面有很多不必要的代码来跟踪问题的来源。我的权限设置为'publish_stream,read_stream'。

我尝试了其他博客中的所有代码,但似乎没有工作我不知道是否因为我使用PHP SDK 3.0 - 最新版本。我的应用程序是iframe app。甚至在Facebook应用程序上买了一本昂贵的书(太贵了),但在购买后发现它已经过时了!

如果我使用/我或我的用户ID但不是我朋友的ID,则代码效果很好。

require 'config.php';
require 'facebook.php';


//Create facebook application instance.
$facebook = new Facebook(array(
  'appId'  => $fb_app_id,
  'secret' => $fb_secret
));


$sent = false;
$userData = null;
$PPnotposted = true;
$me = null;
$test_friends =1;

$user = $facebook->getUser();

// Login or logout url will be needed depending on current user state.
if ($user) {
  $logoutUrl = $facebook->getLogoutUrl(array("next"=> "<? echo $fb_app_url ?>" ));
} else {
  $loginUrl = $facebook->getLoginUrl( array( 'scope'=> 'publish_stream, read_stream', 'redirect_uri' => $fb_app_url));
}

$get_someone_else = 100000xxxxxxxxx; // I used a real user id but covered it up here so
                                     my friend's id hidden for this stackexchange help

if ($user) {
  try {
    // Proceed knowing you have a logged in user who's authenticated.
    if ( $get_someone_else ){
    $user_profile = $facebook->api("/".$get_someone_else);
    echo "<br/> ********************user is ".$get_someone_else." ******************<br/>";
    var_dump( $user_profile );  
    echo "<br/> ********************** end of user info ******************<br/>";   
    } else {
    $user_profile = $facebook->api('/me');
    }
  } catch (FacebookApiException $e) {
  }
// print_r( $user_profile );  
$PPaccesstoken = $facebook->getAccessToken(); 
$attachment[access_token]= $PPaccesstoken ;


    //post message to wall if it is sent through form

    if(isset($_POST['PPmessage'])){
        try {
           if( $get_someone_else ){
          $ppmy_news = $facebook->api("/.$get_someone_else./feed?limit=300");     //Get 300 messages to examine
    echo "<br/> *********************** news feed is ".$ppmy_news." ******************<br/>";
    var_dump( $ppmy_news );  
    echo "<br/> ******************** end of user info ********************<br/>";             
           } else {
          $ppmy_news = $facebook->api('/me/feed?limit=300');  //Get 300 messages 
                                                   //to examine. Initially I set it to
                                                   // 10 messages for testing purposes.
          }


//        var_dump( $ppmy_news);        
//          $sent = $facebook->api("/".$user."/feed", 'POST', $attachment );

          $ppmy_view_lp=0;
          if( $test_friends ) {     //Debugging flag to activate or deactivate parts of code
          echo "sent is :<br />";
//        var_dump( $sent ); 
          echo "<br />";
          $friends = $facebook->api('/me/friends');
          echo "friends is :<br />";
//        var_dump( $friends ); 
          echo "<br />";
                  $friendsLists = $facebook->api('/me/friends');
                  $total_friends = 0;
                  foreach ($friendsLists as $friends) {
                    foreach ($friends as $friend) {
                      $id = $friend['id'];
                      $name = $friend['name'];
                  $total_friends++;  //Get total number of friends
                      echo "friend : ".$name." id is: ".$id." Total friends is : ".$total_friends." <br/> ";
                     }
                  } 
          }
        } catch (FacebookApiException $e) {
        echo "<br/> !!!!!!!!!!!! Error Dump Line 85 !!!!!!!!!!!!! <br/>";
        var_dump( $e );
        echo "<br/> !!!!!!!!!!!! End of Error Dump !!!!!!!!!!!!! <br/>";        
            //do something about it
        }
    }

}

但是我发现我被拒绝了,并且捕获转储是:

!!!!!!!!!!!!错误转储线85 !!!!!!!!!!!!! object(FacebookApiException)#2(7){[“result:protected”] =&gt; array(1){[“error”] =&gt; array(3){[“message”] =&gt; string(72)“(#803)您请求的某些别名不存在:.100000xxxxxxxxx。” [ “型”] =&GT; string(14)“OAuthException”[“code”] =&gt; int(803)}} [“message:protected”] =&gt; string(72)“(#803)您请求的某些别名不存在:.100000xxxxxxxxx。” [ “字符串:私人”] =&GT; string(0)“”[“code:protected”] =&gt; int(0)[“file:protected”] =&gt; string(48)“/home/www/drpetersnews.com/vmt/base_facebook.php”[“line:protected”] =&gt; int(1106)[“trace:private”] =&gt; array(4){[0] =&gt; array(6){[“file”] =&gt; string(48)“/home/www/drpetersnews.com/vmt/base_facebook.php”[“line”] =&gt; int(810)[“function”] =&gt; string(17)“throwAPIException”[“class”] =&gt; string(12)“BaseFacebook”[“type”] =&gt; string(2)“ - &gt;” [ “ARGS”] =&GT; array(1){[0] =&gt; array(1){[“error”] =&gt; array(3){[“message”] =&gt; string(72)“(#803)您请求的某些别名不存在:.100000xxxxxxxxx。” [ “型”] =&GT; string(14)“OAuthException”[“code”] =&gt; int(803)}}}} [1] =&gt; array(4){[“function”] =&gt; string(6)“_ _s”[“class”] =&gt; string(12)“BaseFacebook”[“type”] =&gt; string(2)“ - &gt;” [ “ARGS”] =&GT; array(1){[0] =&gt; string(32)“/。100000xxxxxxxxx./feed?limit=10”}} [2] =&gt; array(4){[“file”] =&gt; string(48)“/home/www/drpetersnews.com/vmt/base_facebook.php”[“line”] =&gt; int(587)[“function”] =&gt; string(20)“call_user_func_array”[“args”] =&gt; array(2){[0] =&gt; array(2){[0] =&gt; &amp; object(Facebook)#1(7){[“appId:protected”] =&gt; string(15)“368XXXXXXXXXX09”[“appSecret:protected”] =&gt; string(32)“eb4216aXXXXXXXXXXXXXXXXXXXXXfe21”[“user:protected”] =&gt; string(15)“1000000yyyyyyyy”[“signedRequest:protected”] =&gt; NULL [“state:protected”] =&gt; NULL [“accessToken:protected”] =&gt; string(119)“AAAFO5a2SKXkBAAXYgZBdPfTbJKQ3XpBgZBQmU2QcXOx7eo18hB5Hox41J7Of7SMZCj7ZCchJrM1ZCN2KLoAoqCmQWUrjwhDJlMQca005w5kgJIrMQ6ZCdM”[“fileUploadSupport:protected”] =&gt; bool(false)} [1] =&gt; string(6)“_ _s”} [1] =&gt; array(1){[0] =&gt; string(32)“/。100000xxxxxxxxx./feed?limit=10”}}} [3] =&gt; array(6){[“file”] =&gt; string(40)“/ home / www / drtersterss / vmt / index.php”[“line”] =&gt; int(54)[“function”] =&gt; string(3)“api”[“class”] =&gt; string(12)“BaseFacebook”[“type”] =&gt; string(2)“ - &gt;” [ “ARGS”] =&GT; array(1){[0] =&gt; string(32)“/。100000xxxxxxxxx./feed?limit=10”}}}} !!!!!!!!!!!!错误转储结束!!!!!!!!!!!!!

请帮我解决,如果我错误地设置了权限以及如何正确设置,请告诉我。

1 个答案:

答案 0 :(得分:0)

代码是正确的,但问题可能在于Facebook的隐私设置。如果您无法在用户的墙上看到帖子,则表示用户已设置隐私设置,使您无法查看帖子。

使用Graph API Explorer工具(https://developers.facebook.com/tools/explorer/)查看是否可以使用它查看用户的Feed。检查一些朋友ID以查看是否有任何人返回数据。

相关问题