Sunday, May 8, 2011

My First Look into the Twitter API

On April 16, the day that I got my first Twitter account (@RaymondSison), I began to look into how you can grab tweets from a Twitter stream of interest. On Yahoo, I searched on "saving Tweets to XML".

This led me to some interesting info at the following blog entry by Anthony Grace, "Twitter - Saving your Tweets", at
http://www.codersbarn.com/post/2009/12/19/Twitter-Saving-your-Tweets.aspx

The author writes the following (and I followed his instructions by using my first Twitter account @RaymondSison):

Recently, I passed the 700 tweet mark and decided to archive what I had. 
But how? I gleaned the following tidbits from "Twitter Tips, Tricks, and Tweets" by Paul McFedries - founder and CEO of Mashable. You can save a local copy of your tweets by entering the following URL in your browser: 
http://twitter.com/statuses/user_timeline/account.xml?count=n 
where account = your account name, and 
n = number of tweets 
This will open n number of your tweets to date in XML in your browser.
When I did this with my own Twitter account, using http://twitter.com/statuses/user_timeline/RaymondSison.xml?count=n I got the following XML for my one and only tweet "Hello World" (from Fort Worth, TX)--and this gave me some new insight in how to get raw tweet data that we can further process as desired.

  <?xml version="1.0" encoding="UTF-8" ?>
- <statuses type="array">
- <status>
  <created_at>Sat Apr 16 22:32:10 +0000 2011</created_at>
  <id>59383607944417280</id>
  <text>Hello World!</text>
  <source>web</source>
  <truncated>false</truncated>
  <favorited>false</favorited>
  <in_reply_to_status_id />
  <in_reply_to_user_id />
  <in_reply_to_screen_name />
  <retweet_count>0</retweet_count>
  <retweeted>false</retweeted>
- <user>
  <id>283239611</id>
  <name>Raymond Sison</name>
  <screen_name>RaymondSison</screen_name>
  <location />
  <description />

_profile_4_normal.png</profile_image_url>
  <url />
  <protected>false</protected>
  <followers_count>0</followers_count>
  <profile_background_color>C0DEED</profile_background_color>
  <profile_text_color>333333</profile_text_color>
  <profile_link_color>0084B4</profile_link_color>
  <profile_sidebar_fill_color>DDEEF6</profile_sidebar_fill_color>
  <profile_sidebar_border_color>C0DEED</profile_sidebar_border_color>
  <friends_count>2</friends_count>
  <created_at>Sat Apr 16 21:59:05 +0000 2011</created_at>
  <favourites_count>0</favourites_count>
  <utc_offset />
  <time_zone />

/theme1/bg.png</profile_background_image_url>
  <profile_background_tile>false</profile_background_tile>
  <profile_use_background_image>true</profile_use_background_image>
  <notifications />
  <geo_enabled>true</geo_enabled>
  <verified>false</verified>
  <following />
  <statuses_count>1</statuses_count>
  <lang>en</lang>
  <contributors_enabled>false</contributors_enabled>
  <follow_request_sent />
  <listed_count>0</listed_count>
  <show_all_inline_media>false</show_all_inline_media>
  <default_profile>true</default_profile>
  <default_profile_image>true</default_profile_image>
  <is_translator>false</is_translator>
  </user>
  <geo />
  <coordinates />
- <place xmlns:georss="http://www.georss.org/georss">
  <id>42e46bc3663a4b5f</id>
  <name>Fort Worth</name>
  <full_name>Fort Worth, TX</full_name>
  <place_type>city</place_type>
  <attributes />
- <bounding_box>
  <georss:polygon>32.551584 -97.549053 32.551584 -97.033715 33.047463
-97.033715 33.047463 -97.549053</georss:polygon>
  </bounding_box>
  <country code="US">United States</country>
  </place>
  <contributors />
  </status>
  </statuses>

No comments:

Post a Comment