[Proposal] Include an example on how to embed latest tweet from a user

fabric
rest

#1

Hey folks, thank you so much for providing us with this tool.

Is it possible that instead of providing us with an example on how to embed a single tweet by id (such as the one we see after installing twitter via Fabric), you would provide us with an example on to embed latest tweet by a user ?

This would give us a better understanding on how to use the twitter API + Fabric Framework since fetching from user is more advanced than displaying a single tweet.

  1. It will teach us how to get a Twitter Account ID
  2. Whether we should also include username or not
  3. How to grab latest tweet by using json

#2

Hey @Sohaeb,

Thanks for the kind words and for reaching out on this! I’ll let the team know you’d love to see a sample of what you mentioned. What language/platform are you using?


#3

thanks bonnell for the quick reply.

iOS + swift.

If I may add another one:

https://docs.fabric.io/apple/twitter/show-tweets.html#display-a-single-tweet, this example:

let client = TWTRAPIClient()
client.loadTweetWithID(“20”) { tweet, error in
if let t = tweet {
self.tweetView.configureWithTweet(t)
} else {
println(“Failed to load Tweet: (error.localizedDescription)”)
}
}

lastly, https://docs.fabric.io/apple/twitter/access-rest-api.html#load-a-single-tweet, The comment of the code says:

// Fetches @jack’s first Tweet

let client = TWTRAPIClient()
client.loadTweetWithID(“20”) { (tweet, error) -> Void in
// handle the response or error
}

Where in the code above did we put jack’s username/id so that we can fetch his tweet with id #2 ? The comment is just plainly confusing. It should have said: How to display a tweet with id #2 instead

And here https://docs.fabric.io/apple/twitter/access-rest-api.html#load-a-user

It would be cool to complete the example to show what can we get from getting the user by id (tweet, etc…)

lastly, (I hope its not to much already). Can you tell me what kind of stuff can we do by load a user by id ?


#4

The loadTweetWithID method is a good match for when you already know the ID of the Tweet you would like to load.

If you are interested in loading the latest Tweet(s) from a specific account you’ll want to create a TWTRUserTimelineDataSource and set the maxTweetsPerRequest to suit your needs.

See the Twitter Kit for iOS user timeline documentation for more information on setting up a user timeline using Swift.


#5

thank you niall.

By the way, I just noticed that my reply to bonnel regarding the “display a single tweet” example is not clear.

I’ve tried to implement the code below in my viewDidLoad(), But it says that tweetView is not defined. I have TwitterKit imported. Maybe I’m missing a protocol or something ?

let client = TWTRAPIClient()
client.loadTweetWithID(“20”) { tweet, error in
if let t = tweet {
self.tweetView.configureWithTweet(t)
} else {
println(“Failed to load Tweet: (error.localizedDescription)”)
}
}