简体   繁体   中英

I am trying to get my friend name and ids with graph api v2.4, but data returns empty:

hi i am trying to fetch Facebook friend list who using my app when i try this function i getting empty data

my sample code

let request: FBSDKGraphRequest = FBSDKGraphRequest(graphPath: "me/friends", parameters: nil, HTTPMethod: "GET")

    request.startWithCompletionHandler { (connection : FBSDKGraphRequestConnection!, result : AnyObject!, error : NSError!) -> Void in
        if error == nil {
            print("Friends are : \(result)")
        } else {
            print("Error Getting Friends \(error)");
        }
    }

and my output is

FBSDKLog: starting with Graph API v2.4, GET requests for /me/friends should  contain an explicit "fields" parameter
ID is: 964865453559288
2015-12-21 18:25:55.635[12226:218972] fb_id 964865453559288
Friends are : {
data =     (
);
}

USE user_id to fetch friends.It is working fine . Try it

-(void)fetchFriendList:(NSString*)userid
{

    NSString *string = [NSString stringWithFormat:@"/%@/taggable_friends",userid];

    FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc]
                                  initWithGraphPath:string
                                  parameters:nil];
    [request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection,
                                          id result,
                                          NSError *error) {

    ///// your results
    }];




}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM