I want to get the twitter profile image. I get the ACAccount. Then I do an SLRequest. The problem is that response is empty...The app is added on the twitter developer site. I never get an OAuth token or even user the keys generated from the developer site in my app. Should I be storing an oauth token and/or using the keys anywhere? For facebook, I set the appID facebook gave me in the plist. Is it similar with twitter api key?
Edit: The response isn't empty. I think there is a binary character in it. But when I print out timelineData, it shows as empty.
-(void)slRequestTwitter:(ACAccount *)selectedTwitterAccount
{
NSURL *url = [NSURL URLWithString:@"https://api.twitter.com/1.1/statuses/user_timeline.json"];
NSDictionary *params = @{@"screen_name" : selectedTwitterAccount.username,
@"include_rts" : @"0",
@"trim_user" : @"1",
@"count" : @"1"};
SLRequest *request =
[SLRequest requestForServiceType:SLServiceTypeTwitter
requestMethod:SLRequestMethodGET
URL:url
parameters:params];
//Attach account to request
[request setAccount:selectedTwitterAccount];
//Execute request
[request performRequestWithHandler:^(NSData *responsedata, NSHTTPURLResponse *urlResponse, NSError *error){
if(responsedata){
if(urlResponse.statusCode >= 200 && urlResponse.statusCode < 300){
NSError *jsonError;
NSDictionary *timelineData = [NSJSONSerialization JSONObjectWithData:responsedata options:NSJSONReadingAllowFragments error:&jsonError];
if(timelineData){
NSLog(@"Timeline Response: %@\n", timelineData);
}
else {
//Json deserialization went wrong
NSLog(@"JSON error: %@ : %s", [jsonError localizedDescription], __PRETTY_FUNCTION__);
}
}
else {
//Server did not respond
NSLog(@"The response status code is %d", urlResponse.statusCode);
}
}
}];
}