I've installed the Twitter SDK in a project via Fabric.app. I'm able to login to my Twitter account, however when I do anything related to requesting tweets, I threw in these print statements:
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 a value:
print("Twitter.sharedInstance().sessionStore.session()?.userID is \(Twitter.sharedInstance().sessionStore.session()?.userID)")
There is a Fabric entry in my Info.plist. I didn't alter or manipulate it from the Fabric.app installation.
In my AppDelegate.swift's didFinishLoadingWithOptions:
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// I tried using the consumerKey/consumerSecret for Fabric & Twitter for S's & G's to no avail
Twitter.sharedInstance().startWithConsumerKey("myConsumerKey", consumerSecret: "myConsumerSecret")
Fabric.with([Twitter.self()])
return true
}
I ran thru Fabric's Twitter setup checklist re: setup and I've done everything, yet I've apparently mucked something up. The sample code from Fabric's website doesn't work "out of the box" for me. Any thoughts re: where to look for the problem? I'm out of ideas.
when you request tweets I imagine your code looks like the following, correct?
let client = TWTRAPIClient()
let dataSource = TWTRUserTimelineDataSource(screenName: "fabric", APIClient: client)
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 info to do its thing. I had the same issue.
Another Change ... It's no longer APIClient it's now apiClient
let userID = Twitter.sharedInstance().sessionStore.session()?.userID
let client = TWTRAPIClient(userID: userID)
let dataSource = TWTRUserTimelineDataSource(screenName: "fabric", apiClient: client)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With