I'm practically new to using the Twitter API, so bear with me for this:
I have no idea how to actually use the API on a website. I don't understand how it's going to be implemented, because most of the tutorials recommend a separate jQuery/Javascript file to go with it, but that just complicates matters for me, because all i want the website to display is the latest tweet i've posted on my website.
So getting back on topic, i've just read a GET statuses/user_timeline API documentation, but how do i actually use these on a website?
If i'm not wrong, i need to send a GET REQUEST to the Twitter servers defining my user_id and only display a count of 1 to display the first latest tweet (which would be returned as a text) on my website.
How do i go about doing that?
The users/show endpoint will handily also return your most latest tweet.
https://dev.twitter.com/docs/api/1/get/users/show
So something like
$.getJSON(
"http://api.twitter.com/1/users/show.json?screen_name=BarackObama&callback=?",
function(data) {
alert(data.status.text);
}
);
should work for you.
The callback=? is for JSONP, to be able to do cross-domain requests.
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