2009-05-18 – Version 0.10
This is release 0.10 of Zen Twitter Tools and the Zen::Twitter library, which currently covers the following:
- Search
- Timeline
- Status
- User
- Direct Message
- Friendship
- Social Graph
- Account
- Favorite
- Notification
- Block
- Help
You can read more about the above function groups at the Twitter API documentation site.
The following scripts are currently included on Zen Twitter Tools v 0.10:
Account Management
account_rate_limit_status.pl – Check your current API limits and how many credits you have left.
account_update_delivery_device.pl – Update delivery device for Twitter notifications.
account_update_profile_color.pl – Update your profile colors.
account_update_profile.pl – Update your profile data.
account_verify_credentials.pl – Test the data on credentials.xml by logging in from the command line.
Block Management
block_blocking.pl – List users you are currently blocking.
block_create.pl – Block a user
block_destroy.pl – Unblock a user
block_exists.pl – Check whether you are currently blocking a user.
block_ids.pl – List IDs of all users you are blocking.
Direct Messages
direct_message_destroy.pl – Delete a Direct Message
direct_message_send.pl – Send a Direct Message
direct_messages.pl – List Direct Messages inbox
direct_messages_sent.pl – List Sent Direct Messages
Favorites
favorite_create.pl – Add a status to your Favorites
favorite_destroy.pl – Remove a status from your Favorites
favorites.pl – List your Favorites
Followers and Friends
followers_not_friends.pl – Lists which followers you have not yet befriended.
friendship_create.pl – Follow a user
friendship_destroy.pl – Unfollow a user
friendship_exists.pl – Check whether user_a follows user_b
friends_not_followers.pl – Lists which friends do not yet follow you back.
friends_timeline.pl – Your friends’ 20 latest updates
mentions.pl – The 20 latest mentions of @you
public_timeline.pl – The Twitter-wide latest 20 updates, updated every 60 seconds.
Notification (Mobile)
notification_follow.pl – Receive mobile notifications for a user.
notification_leave.pl – Stop receiving mobile notifications for a user.
Search
search.pl
Social Graph
socialgraph.pl – Simple friend/follower count.
Status
status_destroy.pl – Delete one of your status messages.
status_show.pl – Show the status of a user.
status_update.pl – Update your status.
Help
test.pl – Tests a simple exchange with the Twitter server to check connectivity.
Users
user_timeline.pl – Retrieve a USER’s timeline(Same data you see on http://twitter.com/USER’s page)
user.pl
Sample Scripts
Sample scripts are provided with each module so you can implement/customize your own tools. The scripts can also be used to directly manipulate your account. All functions requiring authentication need a properly configured credentials.xml file. Setup is very simple, you should not have any problems using the scripts and library.
Not Implemented on v 0.10
The following functions were not implemented on 0.10 :
- Search trends (Reason: did not implement the JSON-only requests yet.)
- Profile image uploads(2 functions: background image and user image).
- Account signoff function. (Not applicable on a stateless CLI environment.)
Download: zen-twitter-tools-0.10.tar.gz
Note: I’ll be working on improving the documentation for the library. For now I’ve quickly annotated each function but did not provide standard CPAN-quality POD’s for all modules.
2009-05-14
I found some Twitter modules on CPAN but the Twitter API seemed fun, it’s well documented and getting more popular by the day, so I felt like having a go at it in Perl.
Bug reports, suggestions and constructive criticism are always welcome.
So far we have some base classes, authentication, HTTP and XML modules in place. The only demos available at this time are the Friend/Follower monitoring scripts.
The Zen::Twitter::User Object
Using Class::Accessor we automate the creation of accessor methods for each field returned in the Twitter user data structure. See below for the vast ammount of user information you can get from a single Zen::Twitter::User object.
| Accessor Method | Description |
| id | Numeric Twitter ID |
| name | Users’s real name |
| screen_name | Twitter nickname, what goes twitter.com/HERE |
| location | Geolocation of the user |
| description | Self-description |
| profile_image_url | User’s photo image url |
| url | The user’s home page |
| protected | String boolean literally ‘true’ or ‘false’, whether user’s updates are protected |
| followers_count | Number of people following this user |
| profile_background_color | 6 character html hex code without the traditional hash# (E.g. ffcc00 for bright orange) |
| profile_text_color | 6 char html hex code for his text color |
| profile_link_color | 6 char html hex code for profile link |
| profile_sidebar_fill_color | 6 char html hex code for sidebar fill |
| profile_sidebar_border_color | 6 char html hex code for profile border color |
| friends_count | Number of friends (people this user is following) |
| created_at | Signup date in format DAYOFWEEK MON DAYOFMONTH HH:MM:SS +-OFFSET YEAR |
| favourites_count | Number of favourites |
| utc_offset | UTC offset |
| time_zone | Time zone |
| profile_background_image_url | Profile background image URL |
| profile_background_tile | String boolean ‘true’ or ‘false’ whether the bg image is tiled |
| statuses_count | Number of updates |
| notifications | String boolean ‘true’ or ‘false’ whether user receives notifications |
| following | Number of people following this user |
Zen::Twitter
The Zen::Twitter module is the general front-end employing direct Twitter functions to create added functionality. For instance, friends_not_followers() and it’s counterpart followers_not_friends() are implemented in it, using 2 direct Twitter functions from Zen::Twitter::Friends to obtain the respective lists and then diff them from each other.
Zen::UserAgent
This is currently a single-function stub really, all it does is create a single point from where our UserAgents are created. We might need to add functionality, so right now it might seem like overkill but it just might come in handy to have all our HTTP User Agent stuff tucked in one namespace.
Zen::Twitter::Authentication
Hides the details of finding and parsing credentials.xml and gives us a Credentials object to pass around wherever authentication is required.
Zen::Twitter::Credentials
A simple Credentials interface. Currently offers username() and password() methods only. Created it so we wouldn’t be passing a hashref around accessing its internals without a proper interface.
Zen::Twitter::Friends
Maybe this one should have been called Zen::Twitter::Users, keeping the names sync’d with Twitter’s. It contains 2 direct Twitter querying functions: friends() and followers(), both return an arrayref of Zen::Twitter::User objects for the user identified by the Credentials passed in.
Zen::Twitter::HTTP
Queries the Twitter XML services and returns Perl data structures parsed by XML::Simple. A Zen::Twitter::User can be directly instantiated from each user tag on the XML returned by the functions described here.
Download
zen-twitter-tools-0.01.tar.gz
That’s all folks! I hope you can use some of this code to create your own Twitter apps(I placed it all under the BSD License, just in case).
2009-05-17 – Version 0.08
- Implemented Block methods, with sample scripts.
Twitter API Sections now Available in Zen::Twitter :
- Search(without ‘trends’)
- Timeline
- Status
- User
- Direct Message
- Friendship
- Social Graph
- Favorite
- Notification
- Block
- Help
Next up in TO DO list: Account Methods
Download: zen-twitter-tools-0.08.tar.gz
Version 0.07
- Implemented Friendship methods, with samples.
- Implemented Social Graph methods. Included sample scripts.
- Implemented Favorite methods, with sample scripts.
- Implemented Notification methods, with sample scripts.
Twitter API Sections now Available in Zen::Twitter :
- Search(without ‘trends’)
- Timeline
- Status
- User
- Direct Message
- Friendship
- Social Graph
- Favorite
- Notification
- Help
Next up in TO DO list: Block Methods
Download: zen-twitter-tools-0.07.tar.gz
Version 0.04
- Implements the 4 Direct Message methods: direct_messages(), sent(), new() and destroy() which allow you to create and send direct messages as well as view the lists of sent and received messages.
Twitter API Sections now Available in Zen::Twitter : Search(without ‘trends’), Timeline, Status, User and Direct Message Methods.
Next up in TO DO list: Friendship Methods
Download: zen-twitter-tools-0.04.tar.gz
Version 0.03
- Implements all 3 Status methods: show(), update() and destroy() which allow you to view any status messages(authentication needed for protected updates), update your own status and destroy your own unwanted updates. Includes 3 example scripts implementing each.
- Implements the single test() Help method. Sample script allows you to “ping” the Twitter servers and test connectivity.
Twitter API Sections now Available in Zen::Twitter : Search(without ‘trends’), Timeline, Status and User Methods.
Next up in TO DO list: Direct Messaging.
Download: zen-twitter-tools-0.03.tar.gz
Version 0.02
- Implements all 4 Timeline Methods : Display public timeline, friends’ timeline, a specific user’s timeline and mentions of you.
- Zen:Twitter::User object is employed on all Timeline results where a user is mentioned
- 4 scripts added to demonstrate the Timeline methods
- Implements Search (No ‘trends’ functionality yet.)
- search.pl script added to demonstrate search functionality
- Filtering/sorting HTTP parameters unimplemented by the library are passed on to Twitter.
Download: zen-twitter-tools-0.02.tar.gz
[...] The examples, as well as the Perl modules, are available in the Zen::Twitter tarball. [...]
Pingback by Zen»Blog Archive » See Which Twitterers Don’t Follow You Back (and vice-versa) In Less Than 15 Lines of…Perl — May 14, 2009 @ 1:55 pm
Love Perl, love public speaking. Will look forward to taking a closer look at this code and look forward to seeing the wonder of Twitter, line by line. Rgds Vince
Comment by vince stevenson — May 19, 2009 @ 5:26 pm