Note that there are some explanatory texts on larger screens.

plurals
  1. POGet my latest Twitter post with PHP
    primarykey
    data
    text
    <p>I'm trying to make a simple site that uses php and the Twitter API to write out my latest post from twitter. I found a tutorial showing me how to get my timeline (or last 20 posts) in xml format, but can't figure out how to print out <strong>just</strong> the latest post, and <strong>just</strong> the text of it (not the time, date, etc that come with the xml/rss/etc).</p> <p>My code looks like this</p> <pre><code>&lt;h2 id = "latest"&gt; &lt;?php var $username='myusername'; var $password='mypassword'; var $responseInfo=array(); function latest_status($format='json',$id=null) { $request = 'http://twitter.com/statuses/user_timeline.'.$format; if($id) { $postargs = "id=$id"; return $this-&gt;process($request,$postargs); } return $this-&gt;process($request); } echo latest_status("json"); ?&gt; &lt;/h2&gt; </code></pre> <p>And it's returning this:</p> <blockquote> <p>[{"contributors":null,"created_at":"Tue Feb 16 19:56:08 +0000 2010","in_reply_to_user_id":null,"source":"API","favorited":false,"in_reply_to_status_id":null,"truncated":false,"user":{"notifications":null,"profile_link_color":"0000ff","description":"","verified":false,"profile_background_tile":false,"created_at":"Tue Feb 16 01:16:15 +0000 2010","profile_background_color":"9ae4e8","profile_image_url":"<a href="http://s.twimg.com/a/1265999168/images/default_profile_1_normal.png" rel="nofollow noreferrer">http://s.twimg.com/a/1265999168/images/default_profile_1_normal.png</a>","time_zone":"Hawaii","profile_sidebar_fill_color":"e0ff92","followers_count":0,"screen_name":"whisperingweb","lang":"en","friends_count":0,"profile_sidebar_border_color":"87bc44","statuses_count":2,"following":null,"protected":false,"favourites_count":1,"location":"","name":"Chris Armstrong","contributors_enabled":false,"profile_text_color":"000000","id":114608397,"geo_enabled":true,"profile_background_image_url":"<a href="http://s.twimg.com/a/1265999168/images/themes/theme1/bg.png" rel="nofollow noreferrer">http://s.twimg.com/a/1265999168/images/themes/theme1/bg.png</a>","utc_offset":-36000,"url":null},"in_reply_to_screen_name":null,"geo":null,"id":9199090048,"text":"Someone was on your website"},{"favorited":false,"source":"web","in_reply_to_user_id":null,"created_at":"Tue Feb 16 18:50:21 +0000 2010","geo":null,"user":{"verified":false,"description":"","notifications":false,"profile_text_color":"000000","screen_name":"whisperingweb","profile_background_image_url":"<a href="http://s.twimg.com/a/1265999168/images/themes/theme1/bg.png" rel="nofollow noreferrer">http://s.twimg.com/a/1265999168/images/themes/theme1/bg.png</a>","url":null,"profile_link_color":"0000ff","followers_count":0,"statuses_count":2,"profile_background_tile":false,"created_at":"Tue Feb 16 01:16:15 +0000 2010","friends_count":0,"profile_background_color":"9ae4e8","contributors_enabled":false,"time_zone":"Hawaii","favourites_count":0,"profile_sidebar_fill_color":"e0ff92","protected":false,"location":"","name":"Chris Armstrong","lang":"en","geo_enabled":true,"profile_sidebar_border_color":"87bc44","id":114608397,"following":false,"utc_offset":-36000,"profile_image_url":"<a href="http://s.twimg.com/a/1265999168/images/default_profile_1_normal.png" rel="nofollow noreferrer">http://s.twimg.com/a/1265999168/images/default_profile_1_normal.png</a>"},"contributors":null,"in_reply_to_status_id":null,"id":9196705546,"in_reply_to_screen_name":null,"truncated":false,"text":"The quick brown fox jumps over the lazy dog"}]</p> </blockquote> <p>I'm pretty new to php, and completely new to the Twitter API, so would appreciate any help or advice.</p> <p><strong>edit: Have changed example from xml to json</strong></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload