Friday, 27 September 2013

Weird Twitter error

Weird Twitter error

I'm trying to access the user's credentials of Twitter with this code :
ACAccountStore *account = [[ACAccountStore alloc] init];
ACAccountType *accountType = [account
accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];
[account requestAccessToAccountsWithType:accountType options:nil
completion:^(BOOL granted, NSError *error)
{
if (granted)
{
NSArray *arrayOfAccounts = [account
accountsWithAccountType:accountType];
if ([arrayOfAccounts count] > 0)
{
ACAccount *twitterAccount = [arrayOfAccounts lastObject];
NSURL *requestURL = [NSURL
URLWithString:@"https:api.twitter.com/1.1/account/verify_credentials.json"];
SLRequest *getRequest = [SLRequest
requestForServiceType:SLServiceTypeTwitter
requestMethod:SLRequestMethodGET
URL:requestURL parameters:nil];
[getRequest setAccount:twitterAccount];
[getRequest performRequestWithHandler:^(NSData
*responseData, NSHTTPURLResponse *urlResponse, NSError
*error) {
NSDictionary *json = [NSJSONSerialization
JSONObjectWithData:responseData options:kNilOptions
error:nil];
NSLog(@"Twitter Response : %@ ",json);
}];
}
};
}];
}
With this code i'm getting this error :
Twitter Response : {
errors = (
{
code = 32;
message = "Could not authenticate you";
}
);
}
The weird thing is that, if i try tweet something or access some other
endpoint of Twitter,where is required to have a oauth-token, the operation
ends successfully.
Thank you all in advance!

No comments:

Post a Comment