{"id":3728,"date":"2009-09-04T06:04:54","date_gmt":"2009-09-04T13:04:54","guid":{"rendered":"http:\/\/css-tricks.com\/?page_id=3728"},"modified":"2013-07-04T07:27:02","modified_gmt":"2013-07-04T14:27:02","slug":"display-last-tweet","status":"publish","type":"page","link":"https:\/\/css-tricks.com\/snippets\/jquery\/display-last-tweet\/","title":{"rendered":"Display Last Tweet"},"content":{"rendered":"
\nThe code below no longer works as-is with the Twitter API update to 1.1 as of 2013-06-11<\/a>. The 1.1 API<\/a> requires oAuth which requires a server side component. Here’s a PHP way<\/a> to interact with the new API. Googling around will find you many other libraries and such. There is an all-JavaScript method<\/a> for getting tweets, but it may be a bit of a loophole that you may not want to count on.\n<\/div>\n
$.getJSON(\"https:\/\/api.twitter.com\/1\/statuses\/user_timeline\/chriscoyier.json?count=1&include_rts=1&callback=?\", function(data) {\r\n     $(\"#twitter\").html(data[0].text);\r\n});<\/code><\/pre>\n

Make sure you change username.json to your actual username and #twitter to the actual selector you wish to replace the contents of.<\/p>\n

You can play around with this on this CodePen<\/a> (deprecated).<\/p>\n","protected":false},"excerpt":{"rendered":"

The code below no longer works as-is with the Twitter API update to 1.1 as of 2013-06-11. The 1.1 API requires oAuth which requires a server side component. Here’s a PHP way to interact with the new API. Googling around will find you many other libraries and such. There is an all-JavaScript method for getting […]<\/p>\n","protected":false},"author":3,"featured_media":0,"parent":3245,"menu_order":0,"comment_status":"open","ping_status":"closed","template":"page-snippet.php","meta":{"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"sig_custom_text":"","sig_image_type":"featured-image","sig_custom_image":0,"sig_is_disabled":false,"inline_featured_image":false,"c2c_always_allow_admin_comments":false,"footnotes":""},"tags":[],"acf":[],"jetpack-related-posts":[{"id":4161,"url":"https:\/\/css-tricks.com\/snippets\/php\/get-latest-twitter-status\/","url_meta":{"origin":3728,"position":0},"title":"Get Latest Twitter Status","date":"September 19, 2009","format":false,"excerpt":"The code below no longer works as-is with the Twitter API update to 1.1 as of 2013-06-11. The 1.1 API requires oAuth which requires a server side component. Here's a PHP way to interact with the new API. Googling around will find you many other libraries and such. There is\u2026","rel":"","context":"In "Article"","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":3459,"url":"https:\/\/css-tricks.com\/snippets\/php\/display-feedburner-feed-count\/","url_meta":{"origin":3728,"position":1},"title":"Display FeedBurner Feed Count","date":"August 20, 2009","format":false,"excerpt":"Replace \"your feedburner id\" with your actual FeedBurner ID. Also, make sure your \"Awareness API\" is turned on in your FeedBurner settings for the particular feed you are pulling from.","rel":"","context":"In "Article"","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":3264,"url":"https:\/\/css-tricks.com\/snippets\/php\/get-feedburner-subscriber-count-with-curl\/","url_meta":{"origin":3728,"position":2},"title":"Get FeedBurner Subscriber Count with cURL","date":"August 6, 2009","format":false,"excerpt":"$ch = curl_init(); curl_setopt($ch,CURLOPT_URL,'https:\/\/feedburner.google.com\/api\/awareness\/1.0\/GetFeedData?id=7qkrmib4r9rscbplq5qgadiiq4'); curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,2); $content = curl_exec($ch); $subscribers = get_match('\/circulation=\"(.*)\"\/isU',$content); curl_close($ch); The $subscribers variable will then be your subscriber count, for echoing out (or whatever). You'll need to replace the ID at the end of the second line with your feed's ID (find it). You'll also need to\u2026","rel":"","context":"In "Article"","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":154528,"url":"https:\/\/css-tricks.com\/lodge\/learn-jquery\/20-data-data-data-attrdata\/","url_meta":{"origin":3728,"position":3},"title":"#20: Data! data-*! .data()! .attr(data-*)!","date":"October 29, 2013","format":false,"excerpt":"Data. In the world of jQuery, it's all about bits of information that are attached directly to elements (rather than, say, a variable with onus only to itself). There is a ton of ways to save bits of data on the \"client side\" (in the browser, rather than the server).\u2026","rel":"","context":"Similar post","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":14897,"url":"https:\/\/css-tricks.com\/snippets\/javascript\/pagevisibility-api\/","url_meta":{"origin":3728,"position":4},"title":"PageVisibility API","date":"November 9, 2011","format":false,"excerpt":"Demo by Sagar Ganatra","rel":"","context":"With 1 comment","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":20797,"url":"https:\/\/css-tricks.com\/lodge\/artists-website\/037-color-manipulation\/","url_meta":{"origin":3728,"position":5},"title":"#037 – Color Manipulation","date":"March 26, 2013","format":false,"excerpt":"Back when we were messing with giving CMS abilities to the homepage slider, we gave a custom field to each homepage slide a color picker. That gives us access to that color wherever we need it. In the template, we'll wrap each slide in a with a data-* attribute where\u2026","rel":"","context":"With 2 comments","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/pages\/3728"}],"collection":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/comments?post=3728"}],"version-history":[{"count":5,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/pages\/3728\/revisions"}],"predecessor-version":[{"id":22291,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/pages\/3728\/revisions\/22291"}],"up":[{"embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/pages\/3245"}],"wp:attachment":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/media?parent=3728"}],"wp:term":[{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/tags?post=3728"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}