Adrian Adrian - 1 year ago 70
iOS Question

Installed Twitter via Fabric, login works, persistent error requesting Tweets

I've installed the Twitter SDK in a project via I'm able to login to my Twitter account, however when I do anything related to requesting tweets, I threw in these


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

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
on my
, I return a value:

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

There is a
entry in my
. I didn't alter or manipulate it from the

In my AppDelegate.swift's

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")
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.

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download