Nupur Rawat
Nupur Rawat

Reputation: 175

How to get user time line in JSON format using Twitter Kit in iOS SDK

I am trying to implement Twitter kit in my App. I have added SDK in my app & able to login. Now I have to get user time line data in JSON format (because I have to perform some manipulation & sorting over data). I found this link on Twitter to get time line for a user but in my case I need data in JSONformat not as DataSource object.

Can anyone suggest how to retrieve the time line data in JSON format using Twitter Kit?

Upvotes: 0

Views: 314

Answers (1)

Ruby Kaushik
Ruby Kaushik

Reputation: 86

TWTRAPIClient has several methods for making request and getting data. Use given code snippet to get user timelines.For parameters, kindly refer this page

let parameters = ["screen_name": "stevenhepting", "count": "3"]
var error : NSError?
let req = TWTRAPIClient().urlRequest(withMethod: "GET", url: "https://api.twitter.com/1.1/statuses/user_timeline.json", parameters: parameters, error: &error)
TWTRAPIClient().sendTwitterRequest(req, completion: { (response, data, error) in
  do {
    let response = try JSONSerialization.jsonObject(with: data!, options: .allowFragments) as? [[String : Any]]
    if response != nil {
      print((response! as NSArray).debugDescription)
    }
  }
  catch {
    print(error.localizedDescription)
  }
})

To get other timelines, please refer Twitter Developer Documentation

Upvotes: 3

Related Questions