iOS Twitter Kit usage gets error 'Request failed: forbidden'
I have quite similar issue to this one and I cannot find an answer as that question wasn't solved.
The problem is that I get this in Xcode's console after setting up Twitter Kit and Fabric, adding secret and api keys for twitter to plist:
Error Domain=TwitterAPIErrorDomain Code=200 "Request failed: forbidden (403)" UserInfo=0x7fdd9ac48ef0 {NSErrorFailingURLKey=https://api.twitter.com/1.1/guest/activate.json, NSLocalizedDescription=Request failed: forbidden (403), NSLocalizedFailureReason=Twitter API error : Forbidden. (code 200)}
My code that uses Twitter Kit and produces the error mentioned above:
NSString *userID = [Twitter sharedInstance].sessionStore.session.userID;
TWTRAPIClient *client = [[TWTRAPIClient alloc] initWithUserID:userID];
[client loadUserWithID:kTwitterUser completion:^ (TWTRUser *user, NSError *error) {
if (error) {
NSLog(@"ERROR CARL %@", error);
} else {
NSLog(@"User %@", user);
}
}];
This is a pretty old question but I wanted to put an answer out there in case anyone comes across this.
This error is more or less indicating that your "consumerKey" and "consumerSecret" are incorrect.
The goofy thing is that there's 3 ways of generating this and they all produce a different key. One is through Twitter dev website, one is created automatically when you install TwitterKit via Fabric app and one is through the Fabric website, when you activate TwitterKit.
All of the variations of the TwitterKit consumerKey/consumerSecrets did not work for me except for the one that I created on the Fabric website.
Log in to the Fabric website, find your app and tap on it and on the left panel select Add Kit. Get through adding the kit and then go back to the app home page and tap on the kit you just added, it should have the correct keys/secrets that you should be using.
Also, make sure you're using this same set of keys in the Plist TwitterKit entry and the AppDelegate initialization.
链接地址: http://www.djcxy.com/p/29258.html