objective c - How to process multiple SLRequest to get friends list in twitter? -


i m using following twitter api friends list: https://api.twitter.com/1.1/friends/list.json?

and using [slrequest performrequestwithhandler:^(nsdata *responsedata, nshttpurlresponse *urlresponse, nserror *error) response data, , perform ui changes , model data changes in performrequestwithhandler block.

but single request @ maximum retrieves 20 friends.(if set cursor parameter in api -1).

i can use cursor parameter of api send request next 20 friends , on until cursor value 0. cursor parameter can set 'next_cursor' parameter in response data of previous request.

but m not aware of how call slrequest in performrequestwithhandler of previous request, until 'next_cursor' value in response data of previous request 0.

can tell me how friends using slrequest or using other way.

any appreciated.

thank you.

u can call next request in request handler after response of twitter friends.

sorry not elaborating. thought understand. here code.

    acaccountstore *account = [[acaccountstore alloc] init];         acaccounttype *accounttype = [account accounttypewithaccounttypeidentifier:acaccounttypeidentifiertwitter];          // request access user access twitter account         [account requestaccesstoaccountswithtype:accounttype options:nil completion:^(bool granted, nserror *error)          {              // did user allow access?              if (granted == yes)              {                  // populate array available twitter accounts                  nsarray *arrayofaccounts = [account accountswithaccounttype:accounttype];                   // sanity check                  if ([arrayofaccounts count] > 0)                  {                       [self postrequest];                   }              }          }];  - (void)postrequest {        // keep simple, use first account available                      acaccount *acct = [arrayofaccounts objectatindex:0];                       nsmutabledictionary *tempdict = [[nsmutabledictionary alloc] init];                      [tempdict setvalue:@"posting video" forkey:@"status"];                       // build twitter request                       slrequest *postrequest = [slrequest requestforservicetype:slservicetypetwitter requestmethod:slrequestmethodpost url:[nsurl urlwithstring:@"https://api.twitter.com/1.1/statuses/update.json"] parameters:tempdict];                       [postrequest setaccount:acct];                       [postrequest performrequestwithhandler:^(nsdata *responsedata, nshttpurlresponse *urlresponse, nserror *error) {                          nslog(@"twitter response, http response: %i", [urlresponse statuscode]);                          nsstring *output = [[nsstring alloc] initwithdata:responsedata encoding:nsutf8stringencoding];                          nslog(@"%@", output); **// calling again , again multiple post request.** [self postrequest]                      }]; } 

similar thing can done friend list too.

hope helped.


Comments

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -