Installed Twitter via Fabric, login, persistent error with Tweets request

I installed the Twitter SDK into the project via Fabric.app. I can log in to my Twitter account, but when I do something related to requesting tweets, I threw these print instructions:

 print("Failed to load tweets: \(error!.localizedDescription)") print(error?.localizedFailureReason) 

and get this error:

 Failed to load tweets: Request failed: forbidden (403) Optional("Twitter API error : Unable to verify your credentials (code 99)") 

but when I add this line to viewDidLoad on my TVC , I return the value:

 print("Twitter.sharedInstance().sessionStore.session()?.userID is \(Twitter.sharedInstance().sessionStore.session()?.userID)") 

There is a Fabric entry in my Info.plist . I did not modify or manipulate it when installing Fabric.app .

In my AppDelegate.swift didFinishLoadingWithOptions :

 func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { // I tried using the consumerKey/consumerSecret for Fabric & Twitter for S & G to no avail Twitter.sharedInstance().startWithConsumerKey("myConsumerKey", consumerSecret: "myConsumerSecret") Fabric.with([Twitter.self()]) return true } 

I ran the Fabric Twitter Settings Checklist, which was configured, and I did everything, but I obviously did something. Sample code from the Fabric website does not work out of the box for me. Any thoughts: where to look for a problem? I have no ideas.

+7
ios swift twitter twitter-fabric fabric-twitter
source share
2 answers

when you request tweets, I assume your code is as follows: "

 let client = TWTRAPIClient() let dataSource = TWTRUserTimelineDataSource(screenName: "fabric", APIClient: client) 

It turns out their documentation is incomplete, it should look like

 let userID = Twitter.sharedInstance().sessionStore.session()?.userID let client = TWTRAPIClient(userID: userID) let dataSource = TWTRUserTimelineDataSource(screenName: "fabric", APIClient: client) 

The client object needs your user information in order to do its job. I had the same problem.

+5
source share

Another change ... This is not APIClient now apiClient

 let userID = Twitter.sharedInstance().sessionStore.session()?.userID let client = TWTRAPIClient(userID: userID) let dataSource = TWTRUserTimelineDataSource(screenName: "fabric", apiClient: client) 
+1
source share

All Articles