I was developing and testing an app on my iPhone 4, and it was great. I tested my twitter code, and it worked well. I would retrieve the user's account, and then follow a certain account.
Today, I tried to install and test the app on two other devices, but it just ain't workin!
The response:
{"errors":[{"message":"Bad Authentication data","code":215}]}
The code:
- (void)followApp {
if (!self.account) {
[self _signInWithHandler:^{
[self followApp];
}];
return;
}
NSURL *feedURL = [NSURL URLWithString:@"https://api.twitter.com/1.1/friendships/create.json"];
NSDictionary *parameters = @{
@"follow" : @"true",
@"screen_name" : [MCAppManager sharedManager].applicationTwitterHandle
};
TWRequest *twitterFeed = [[TWRequest alloc] initWithURL:feedURL
parameters:parameters
requestMethod:TWRequestMethodPOST];
twitterFeed.account = self.account;
// Perform the twitter request
[twitterFeed performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) {
if (!error) {
NSLog(@"response: %@", [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding]);
} else {
dispatch_async(dispatch_get_main_queue(), ^{
self.isFollowing = NO;
MCAlertError([error localizedDescription]);
});
}
}];
self.isFollowing = YES;
}
EDIT:
OK, it seems that the reason is that the twitter accounts on the other devices were added without their password. I went to the settings app, and the accounts were just there without passwords.
This isn't really the ultimate answer, but at least it explains where the error is coming from.