i trying fetch 'taggable_friends' list facebook, there may more 1000 taggable friends, facebook paginates results. here method.
-(void)getsfbtaggablefriends:(nsstring *)nextcursor dicfbfriends:(nsmutablearray *) dicfriends failure:(void (^) (nserror *error))failurehandler { nsstring *qry = @"/me/taggable_friends"; nsmutabledictionary *parameters; if (nextcursor == nil) { parameters = nil; } else { parameters = [[nsmutabledictionary alloc] init]; [parameters setvalue:nextcursor forkey:@"next"]; } [fbrequestconnection startwithgraphpath:qry parameters:parameters httpmethod:@"get" completionhandler:^( fbrequestconnection *connection, id result, nserror *error ) { if (error) { nslog(@"%@", [error localizeddescription]); }else { /* handle result */ nsmutabledictionary *mdicresult = [[nsmutabledictionary alloc]initwithdictionary:result]; (nsdictionary * fbitem in [mdicresult valueforkey:@"data"]) { [dicfriends addobject:fbitem]; } // if 'next' value found, call recursively if ([[mdicresult valueforkey:@"paging"] objectforkey:@"next"] != nil) { nsstring *nextcursor = mdicresult[@"paging"][@"next"]; nslog(@"next:%@", [nextcursor substringfromindex:27]); [self getsfbtaggablefriends:nextcursor dicfbfriends:dicfriends failure:^(nserror *error) { failurehandler(error); }]; } } }]; }
problem: first 1000 records in 'result' object , value of 'next' key passed "parameters" parameter recursive call. however, second iteration doesn't paginate & keeps returning same 1000 records.
i tried using nextcursor
value startwithgraphpath
parameter second call instead. resulted in different response object keys og_object
, share
, id
instead of data
& paging
.
please obtain taggable friends page page, long 'next' value present in response object. thank you.
use returned next
endpoint (graph path portion, including cursor) new graph path subsequent request, instead putting parameter.