Composing a tweet with the TWTRComposerViewController and a TWTRCardConfiguration results in a 403 Forbidden error

ios
fabric
api

#1

I’m trying to present a TWTRComposerViewController that will allow the user to share an image (and optionally enter text) using code taken directly from the Fabric documentation. I already have Twitter login and server-side sharing implemented and everything works fine (including the native twitter share sheet provided by iOS). Every time I present this card and hit “Tweet” I get the following error:

Error Domain=TwitterAPIErrorDomain Code=200 "Request failed: forbidden (403)" UserInfo={NSErrorFailingURLKey=https://caps.twitter.com/v2/cards/create.json, NSLocalizedDescription=Request failed: forbidden (403), NSLocalizedFailureReason=Twitter API error : Forbidden. (code 200)}

Here’s the code I’m using to present the composer:

        NSString *userID = [[[[Twitter sharedInstance] sessionStore] session] userID];
        
        // Will be a user generated image later on
        UIImage *image = [UIImage imageNamed:@"UserGeneratedImage"];
        
        // Create the card and composer (in my actual code, I use the real App Store ID obviously)
        TWTRCardConfiguration *card = [TWTRCardConfiguration appCardConfigurationWithPromoImage:image iPhoneAppID:@"SampleAppStoreID" iPadAppID:nil googlePlayAppID:nil];
        
        TWTRComposerViewController *composer = [[TWTRComposerViewController alloc] initWithUserID:userID cardConfiguration:card];
        
        // Set self as the delegate
        composer.delegate = self;
        
        // Show the view controller
        [self presentViewController:composer animated:YES completion:nil];

Any idea why this would be happening? I already contacted the support and they first told me that it was because my app account was suspended but after inquiring further, I’ve been told multiple times that this is actually not the case and that my account has no suspensions of any kind on it and that I should be able to post tweets without issue.

Thanks for the help!


#2

@mad102190 As a quick test, if you don’t try to use a TWTRCard does the compose work?

-Mike


#3

@bonnell Yeah if I just use the TWTRComposer by itself it will bring up the iOS native share sheet, and it will work, but if I use the TWTRCard it will bring up Twitter’s UI and it will always return the Forbidden error


#4

Thanks @mad102190 is this always for an app card?


#5

Hi guys- were you able to get this working? I have the same issue, although I am receiving a 401 error:

ComposeViewController: Error Domain=TWTRNetworkingErrorDomain Code=-1011 "Request failed: unauthorized (401)" UserInfo={NSErrorFailingURLKey=https://caps.twitter.com/v2/cards/create.json, NSLocalizedDescription=Request failed: unauthorized (401), NSLocalizedFailureReason=}

My login session appears to be ok, because this only fails when combining TWTRCardConfiguration and TWTRComposerViewController… if I instantiate TWTRComposerViewController without the cardConfiguration argument, things work fine. And if I create a tweet using TWTRComposer things work fine.


iOS Tweet with App Card
#6