Get user_timeline in Twitter in Swift ?

Twitter API of user_timeline returns the collection if the most recents tweets posted by user. User have to call user_timeline API by screen_name or user_id parameter. This Method returns up to 3200 most recents tweets of user. 


Code to get user_timeline : 

let parameter : [String : AnyObject] = ["screen_name" : (session?.userName)! , "count" : "200"]
let request = Twitter.sharedInstance().APIClient.URLRequestWithMethod("GET", URL: "https://api.twitter.com/1.1/statuses/user_timeline.json", parameters: parameter, error: nil)
var response : NSURLResponse?
let data = try! NSURLConnection.sendSynchronousRequest(request, returningResponse: &response)
let arrayRep = try! NSJSONSerialization.JSONObjectWithData(data, options: NSJSONReadingOptions.AllowFragments)
print(arrayRep)
How to get Screen_name or user_id from twitter ?

The above code have passing two parameter screen_name and count . When user login in twitter then user got screen_name and user_id.

Some useful parameter when request a user timeline.

user_id : This is id of user twitter login.

screen_name : The screen name of user login.

since_id : This id return the result grater then this Id.

count :  returns the umber of tweets 

max_id : return the tweets less then or equal to max_id.

include_rts : set the bool value, if it is true then returns all tweets and retweets. 

Thanks.

Get user_timeline in Twitter in Swift ? Get user_timeline in Twitter in Swift ? Reviewed by KIRIT MODI on 04:06:00 Rating: 5

No comments:

Powered by Blogger.