【问题标题】:Facebook android graph api How to get friends requests count?Facebook android graph api 如何获取好友请求计数?
【发布时间】:2015-02-04 20:00:57
【问题描述】:

有人知道如何使用 Graph API 2.0+ 获取好友请求计数吗? /me/friendrequests 路径不再起作用:

{
  "error": {
    "message": "(#12) friend requests is deprecated for versions v2.0 and higher", 
  "type": "OAuthException", 
  "code": 12
  }
}

而且我不能在 android SDK 中选择较低的 API 级别。

【问题讨论】:

    标签: android facebook facebook-graph-api mobile


    【解决方案1】:

    这已经不可能了。没有其他 API 可以使用

    【讨论】:

      【解决方案2】:

      您可以使用以下方法获取朋友数:

      -(void)getFriendList
      {

      FBRequest* friendsRequest = [FBRequest requestWithGraphPath:@"me?fields=friends.fields(first_name,last_name)" parameters:nil HTTPMethod:@"GET"];
      [friendsRequest startWithCompletionHandler: ^(FBRequestConnection *connection,
                                                    NSDictionary* result,
                                                    NSError *error) {
          NSDictionary* friendsDic = [result objectForKey:@"friends"];
          NSArray *friends = [friendsDic objectForKey:@"data"];
          for (NSDictionary *friend in friends) {
              NSLog(@"firstname %@",friend[@"first_name"]);
              NSLog(@"last name %@",friend[@"last_name"]);
          }
      }];
      

      }

      【讨论】:

      • 我需要计算对我朋友的请求数,而不是我的朋友数。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-10-25
      • 1970-01-01
      相关资源
      最近更新 更多