objective c - Facebook iOS SDK - fetching user albums -
i using facebook sdk in iphone app. want find user's facebook profile photos, using below code:
-(ibaction)facebooklogin:(id)sender{ if (fbsession.activesession.isopen) { [self findalbums]; } else { nsarray *permissions = [[nsarray alloc] initwithobjects:@"user_photos", nil]; [fbsession openactivesessionwithpermissions:permissions allowloginui:yes completionhandler:^(fbsession *session, fbsessionstate status, nserror *error) { // if login fails reason, alert if (error) { } else if (fb_issessionopenwithstate(status)) { [[fbrequest requestforme] startwithcompletionhandler: ^(fbrequestconnection *connection, nsdictionary<fbgraphuser> *user, nserror *error) { if (!error) { [self findalbums]; } }]; } }]; } } -(void)findalbums { [fbrequestconnection startwithgraphpath:@"/me/albums" parameters:nil httpmethod:@"get" completionhandler:^( fbrequestconnection *connection, id result, nserror *error ) { /* handle result */ nslog(@"result::%@",result); }]; }
out put ---- data = ( );
this not give albums in data. facebook user logged in have many albums , photos in profile. why happens?
just change code in find albums :
[fbrequestconnection startwithgraphpath:@"me/albums" completionhandler:^(fbrequestconnection *connection, id result, nserror *error) { if (!error) { // success! include code handle results here nslog(@"user events: %@", result); nsarray *feed =[result objectforkey:@"data"]; (nsdictionary *dict in feed) { nslog(@"first %@",dict); } } else { // error occurred, need handle error // check out our error handling guide: https://developers.facebook.com/docs/ios/errors/ nslog(@"error %@", error.description); } }];
Comments
Post a Comment