iphone - How to use iOS TWRequest for iOS 5 for getting Twitter User Details -
how use twrequest both ios 5 getting twitter user details,
twrequest working earlier , using in way
nsurl *url = [nsurl urlwithstring:@"https://api.twitter.com/1/users/show.json"]; nsdictionary *params = [nsdictionary dictionarywithobjectsandkeys:twittername,@"screen_name",nil]; request = [[twrequest alloc] initwithurl:url parameters:params requestmethod:twrequestmethodget];
but recently, twitter closed api version 1 , implemented version 1.1, , presently above logic not working in ios 5, due api deprecation may be...
i using slrequest ios 6 working perfect, know how can twitter user details in ios 5
try :
nsurl *url = [nsurl urlwithstring:@"https://api.twitter.com/1.1/users/show.json"]; nsdictionary *params = [nsdictionary dictionarywithobjectsandkeys:twittername,@"screen_name",nil]; request = [[twrequest alloc] initwithurl:url parameters:params requestmethod:twrequestmethodget]; acaccountstore *accountstore = [[acaccountstore alloc] init]; acaccounttype *twitteraccounttype = [accountstore accounttypewithaccounttypeidentifier:acaccounttypeidentifiertwitter]; nsarray *twitteraccounts = [accountstore accountswithaccounttype:twitteraccounttype]; // runing on ios 6 if (nsclassfromstring(@"slcomposeviewcontroller") && [slcomposeviewcontroller isavailableforservicetype:slservicetypetwitter]) { [accountstore requestaccesstoaccountswithtype:twitteraccounttype options:null completion:^(bool granted, nserror *error) { if (granted) { slrequest *request = [slrequest requestforservicetype:slservicetypetwitter requestmethod:slrequestmethodget url:url parameters:parameters]; [request setaccount:[twitteraccounts lastobject]]; dispatch_async(dispatch_get_main_queue(), ^ { [nsurlconnection sendasynchronousrequest:request.preparedurlrequest queue:[[nsoperationqueue alloc] init] completionhandler:^(nsurlresponse *response1, nsdata *data, nserror *error) { dispatch_async(dispatch_get_main_queue(), ^ { if (data) { [self loaddata:data]; } }); }]; }); } }]; } else if (nsclassfromstring(@"twtweetcomposeviewcontroller") && [twtweetcomposeviewcontroller cansendtweet]) // runing on ios 5 { [accountstore requestaccesstoaccountswithtype:twitteraccounttype withcompletionhandler:^(bool granted, nserror *error) { if (granted) { twrequest *request = [[twrequest alloc] initwithurl:url parameters:parameters requestmethod:twrequestmethodget]; [request setaccount:[twitteraccounts lastobject]]; dispatch_async(dispatch_get_main_queue(), ^ { [nsurlconnection sendasynchronousrequest:request.signedurlrequest queue:[[nsoperationqueue alloc] init] completionhandler:^(nsurlresponse *response1, nsdata *data, nserror *error) { dispatch_async(dispatch_get_main_queue(), ^ { if (data) { [self loaddata:data]; } }); }]; }); } }]; } }
Comments
Post a Comment