【问题标题】:Unable to read or post to friends wall (news feed)无法阅读或发布到朋友墙(新闻源)
【发布时间】:2012-05-29 15:07:28
【问题描述】:

我一直在尝试阅读朋友的新闻提要,以检查我的消息是否存在(无论消息是可见、隐藏还是删除),如果消息存在,则不要发布新消息。如果它不存在,则发布消息。下面的代码有很多不必要的代码来追踪问题的来源。我为“publish_stream,read_stream”设置了权限。

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

如果我使用 /me 或我的用户 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"]=> array(1) { ["error"]=> array(3) { ["message"]=> string(72) "(# 803)您请求的某些别名不存在:.100000xxxxxxxxx。” ["type"]=> string(14) "OAuthException" ["code"]=> int(803) } } ["message:protected"]=> string(72) "(#803) 你的一些别名请求的不存在:.100000xxxxxxxxx。” ["string:private"]=> string(0) "" ["code:protected"]=> int(0) ["file:protected"]=> string(48) "/home/www/drpetersnews.com /vmt/base_facebook.php" ["line:protected"]=> int(1106) ["trace:private"]=> array(4) { [0]=> array(6) { ["file"]= > string(48) "/home/www/drpetersnews.com/vmt/base_facebook.php" ["line"]=> int(810) ["function"]=> string(17) "throwAPIException" ["class" ]=> string(12) "BaseFacebook" ["type"]=> string(2) "->" ["args"]=> array(1) { [0]=> array(1) { ["error "]=> array(3) { ["message"]=> string(72) "(#803) 您请求的某些别名不存在:.100000xxxxxxxxx。" ["type"]=> string(14) "OAuthException" ["code"]=> int(803) } } } } [1]=> array(4) { ["function"]=> string(6) "_graph" ["class"]=> string(12) "BaseFacebook" ["type"]=> string(2) "->" ["args"]=> array(1) { [0]=> string (32) "/.100000xxxxxxxxx./feed?limit=10" } } [2]=> 数组(4) { ["file"]=> 字符串(48) "/home/www/drpetersnews.com/vmt/ base_facebook.php" ["line"]=> int(587) ["function"]=> string(20) "call_user_func_array" ["args"]=> array(2) { [0]=> array(2) { [0]=> &object(Facebook)#1 (7) { ["appId:protected"]=> 字符串(15) "368XXXXXXXXXX09" ["appSecret:protected"]=> 字符串(32) "eb4216aXXXXXXXXXXXXXXXXXXXXXfe21" ["用户:受保护的 “] =>串(15) ”1000000yyyyyyyy“[” signedRequest:保护 “] => NULL [” 状态:保护 “] => NULL [” 的accessToken:保护“] =>串(119) ”AAAFO5a2SKXkBAAXYgZBdPfTbJKQ3XpBgZBQmU2QcXOx7eo18hB5Hox41J7Of7SMZCj7ZCchJrM1ZCN2KLoAoqCmQWUrjwhDJlMQca005w5kgJIrMQ6ZCdM“ ["fileUploadSupport:protected"]=> bool(false) } [1]=> string(6) "_graph" } [1]=> array(1) { [0]=> string(32) "/.1 00000xxxxxxxxx./feed?limit=10" } } } [3]=> array(6) { ["file"]=> string(40) "/home/www/drpetersnews.com/vmt/index.php" [ "line"]=> int(54) ["function"]=> string(3) "api" ["class"]=> string(12) "BaseFacebook" ["type"]=> string(2) " ->" ["args"]=> 数组(1) { [0]=> 字符串(32) "/.100000xxxxxxxxx./feed?limit=10" } } } } !!!!!!!!!!!!错误转储结束!!!!!!!!!!!!!

请帮帮我,让我知道我是否设置了错误的权限以及如何正确设置。

【问题讨论】:

  • 错误消息非常简单:“您请求的某些别名不存在:.100000xxxxxxxxx”。你确定这是正确的 id 吗?
  • 非常感谢您的回复。是的,id 是正确的,只是我在这里更改了它,这样我就不会将我朋友的 id 暴露给公众。
  • 我明白这一点,但如果你用谷歌搜索特定的错误消息,你会发现通常人们在收到该消息时使用了错误的 ID。
  • 我知道。我从程序中的循环中提取了朋友ID,然后复制并粘贴到笔记本中。我尝试过使用其他朋友 ID,但结果相同。如果我使用我的 ID,它会在我的个人资料中而不是在我的新闻提要中提取消息。
  • 过去几天我一直在解决这个问题,直到凌晨 4:30,然后早上 8 点起床继续。我看了这么多博客,都找不到工作。然后刚才我想起了一个博客(上帝保佑写那个博客的人)提到/me/home而不是/me/feed,我刚刚测试了它。它从我的新闻提要而不是个人资料中获取!但它不会从我朋友家中接听 - 仍然是同样的错误。

标签: php facebook facebook-apps


【解决方案1】:

代码正确,但问题可能出在 Facebook 的隐私设置上。如果您看不到用户墙上的帖子,则表示用户设置了隐私设置,阻止您看到帖子。

使用 Graph API Explorer 工具 (https://developers.facebook.com/tools/explorer/),看看您是否可以使用它查看用户的提要。检查多个朋友 ID 以查看其中是否有任何返回数据。

【讨论】:

  • 感谢您的回复。我使用了 Graph API 浏览器,当我输入个人朋友 ID 时,可以看到他们的一些“连接提要”,但看不到我测试过的那些“连接主页”。但是当我使用该应用程序时,我收到了错误提示。
  • 您是否在 Graph API Explorer 中将应用程序设置为您的应用程序?默认情况下,它使用 Graph API 应用程序。看看结果是不是一样。
  • 对不起,我刚才确实犯了一个错误......我没有意识到我没有将应用程序设置为我的应用程序。我只是将它设置到我的应用程序中,“连接提要”和“连接帖子”在 Graph API Explorer 中为我的许多朋友返回了大量数据。但我的应用没有。
  • 因此可能是影响应用程序的隐私设置或您在应用程序中可能需要的其他权限。您是否获得任何用户 ID 的数据?在测试中,我能看到一些朋友的数据,而另一些则不能。
  • 抱歉耽搁了,我正在清理我的代码并删除所有调试信息,然后我会回去跟踪这个问题
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多