1

私はこの投稿とほとんど同じ問題を抱えています: iOS Facebook SDK: An active access token must be used to query information about the current user , しかし、解決策は私にとってはうまくいかないようです.

メソッドの前半で、これを呼び出します。

NSArray *permissions = [[NSArray alloc] initWithObjects:
                        @"user_photos",
                        @"user_status",
                        @"read_stream",
                        nil];

self.fb = [[FBSession alloc] initWithPermissions:permissions];
[self.fb openWithCompletionHandler:^(FBSession *session,
                                     FBSessionState status,
                                     NSError *error)
 {
     if(!error){
    NSLog(@"Facebook Authorized");
}
     if(error){

         NSLog(@"Error in fb auth request: %@", error.localizedDescription);

     }
        }];

そして、ユーザーアクセスで正常にログインしました。次に、ユーザーの最近の投稿を取得する必要があるため、次のようにします: (FQL)

NSMutableArray *postIDArray = [[NSMutableArray alloc]init];


NSString *query = @"SELECT post_id FROM stream WHERE source_id = me() AND is_hidden = 0 ORDER BY created_time DESC LIMIT 10";

//this was the solution the other SO answer had.
[FBSession setActiveSession:self.fb];

// Set up the query parameter
NSDictionary *queryParam = @{ @"q": query };
// Make the API request that uses FQL
[FBRequestConnection startWithGraphPath:@"/fql"
                             parameters:queryParam
                             HTTPMethod:@"GET"
                      completionHandler:^(FBRequestConnection *connection,
                                          id result,
                                          NSError *error) {
                                                       if (error) {
                              NSLog(@"Error: %@", [error localizedDescription]);
                          } else if(!error) {

                                NSLog(@"Result: %@", result);
                            NSDictionary *resultDict = (NSDictionary *)result;
                              NSArray *postArr = [resultDict objectForKey:@"data"];

                              for (FBGraphObject *friendObj in postArr) {
                                  NSString *postIDString = [friendObj objectForKey:@"post_id"];
                                  [postIDArray addObject:postIDString];
                              }

                              NSLog(@"postidarray array  : %@", postIDArray);

                              //with post ids, loop through and use graph api to get the post details.
                              for (int i = 0; i <= postIDArray.count; i++) {

                                  NSString *path = [NSString stringWithFormat:@"https://graph.facebook.com/me/%@",[postIDArray objectAtIndex:i] ];


                                  NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];
                                  [request setURL:[NSURL URLWithString:path]];
                                 NSData* result = [NSURLConnection sendSynchronousRequest:request  returningResponse:nil error:&error];
                                  NSDictionary *postDict = [result yajl_JSON];
                                  NSLog(@"post %d contents: %@",i, postDict);
                                  }
                }
                      }];
        }

私はpost_IDの罰金を得ることができますが、それから私が電話しようとすると

https://graph.facebook.com/me/<my_post_id>

返されるデータは次のとおりです。

  error =     {
    code = 2500;
    message = "An active access token must be used to query information about the current user.";
    type = OAuthException;
};
}

何が起こっているのか分かりますか?前もって感謝します。

編集:私は使用しようとしました

 [FBRequestConnection startWithGraphPath:postIDString id result, NSError *error) {
          if (error) {
    NSLog(@"Error: %@", [error localizedDescription]);
                } else if(!error) { 
//do some parsing stuff

}

しかし、次のエラーが表示されます: エラー: 操作を完了できませんでした。(com.facebook.sdk エラー 5.)

4

0 に答える 0