Twitter API Library 0.2 in Near Future
Some of the current issues with the Twitter API Library seem to be with the Twitter OAuth library we’re using courtesy of Abraham Williams. I looked into simply updating the code to the newer version of TwitterOAuth, but it seems that are multiple incompatibilities that prevent us from doing so, requiring a rewrite of some of the automated authentication code. As much of a bad thing that this is, it is a good thing as well, and hopefully the newer version of our library will add some much desired features.
Until then, v0.1 will still work for most things.
Twitter API Library – Build 8
I’d like to introduce Build 8 to the masses. Sorry for the long delay in posting, but I was working on a new Twitter Client, TwCLI (which uses the Twitter API Library and is Open Source).
Build 8 contains unsupported support for Twitter Lists. Basically, we have built Twitter lists into the library, but a large number of functions are not working for what seems to be an incompatibility between our OAuth Libraries and Twitter.
Change Log:
- Added array api->lists_update( string $old_name, string $new_name = null, string $privacy = null) [Working]
- Added array api->lists_get( string $screen_name = null, int $cursor = null)
$screen_name defaults to the logged in user if set as null. [Working] - Added array api->lists_display( string $screen_name, string $list_slug) [Unverified]
- Added array api->lists_statuses( string $screen_name, string $list_slug, int $since_id = null, int $max_id = null, int $count = null, int $page = null) [Working]
- Added array api->lists_memberships( string $screen_name, string $list_slug, int $cursor = null) [Unverified]
- Added array api->lists_subscriptions( string $screen_name = null )
$screen_name defaults to the logged in user if set as null. [Unverified] - Added array api->lists_destroy( string $list_slug ) [Not Working]
- Added array api->list_members( string $screen_name, string $list_slug, int $cursor = null ) [Unverified]
- Added array api->list_membersAdd( string $list_slug, int $user_id ) [Working]
- Added array api->list_membersDelete( string $list_slug, int $user_id ) [Unverified]
- Added array api->list_isMember( string $screen_name, string $list_slug, string $screen_name_to_check ) [Unverified]
- Added array api->list_subscribers( string $screen_name, string $list_slug, int $cursor = null) [Unverified]
- Added array api->list_subscribe( string $screen_name, string $list_slug ) [Unverified]
- Added array api->list_unsubscribe( string $screen_name, string $list_slug ) [Unverified]
- Added array api->isSubscriber( string $screen_name, string $list_slug, string $screen_name_to_check ) [Unverified]
Known Issues:
- No Support for Unauthenticated Requests.
- $tw->name() does not support users other than the currently logged in user.
- $tw->profile_pic() does not support users other than the currently logged in user.
- $twitter->get_sn_from_id() does not support users other than the currently logged in user.
- $twitter->get_name_from_id() does not support users other than the currently logged in user.
- Two instances of Twitter API Library can not co-exist on the same sub-domain.
- $twitter->api->lists_destroy() is returning “Incorrect Signature.”
Twitter API Library – Build 7
Well, this is going to break some things if you’re using an older build. Primarily any method that required the ID/Screen Name/User ID of a user. I thought I had pushed out this change before the Build 4 release, but apparently it was still on my computer.
Now, any API methods that were function( mixed $id = NULL, string $screen_name = NULL, int $user_id = NULL ) are now: function( mixed $id, int $id_type = TWITTER_ID ). $id_type can be one of “TWITTER_ID” (lets twitter decide if you’re using a screen name or user id), “TWITTER_SN” (tells twitter you’re using a screen name) or “TWITTER_UID” (tells twitter you’re using a user ID). This parameter may be omitted and will default to TWITTER_ID.
URI: http://sandbox.gtaero.net/twitter_api/code.php?b=7
Change Log:
- Changed Tri-optional User Identification procedure in the API methods to Two Parameters $id and $id_type.
- Added array api->lists_create( string $name [, int $privacy = TWITTER_PRIVACY_PUBLIC ] )
- $privacy may be one of TWITTER_PRIVACY_PUBLIC or TWITTER_PRIVACY_PRIVATE
Known Issues:
- No Support for Unauthenticated Requests.
- $tw->name() does not support users other than the currently logged in user.
- $tw->profile_pic() does not support users other than the currently logged in user.
- $twitter->get_sn_from_id() does not support users other than the currently logged in user.
- $twitter->get_name_from_id() does not support users other than the currently logged in user.
- Two instances of Twitter API Library can not co-exist on the same sub-domain. (All Versions)
Twitter API Library – Build 6
Decided to push out one last, though much smaller, build tonight – Build 6. Build 6 moves from Authorize to Authenticate and adds a TWML function. There are some other small changes in Build 6 from the other builds, but these are not documented yet, and will probably require the help of someone who knows more about OAuth than I to become supported (yes, I’m talking about setup_login() and set_cache_dir()).
URI: http://sandbox.gtaero.net/twitter_api/code.php?b=6
Change Log:
- Moved from using OAuth Authorize to OAuth Authenticate. Users will no longer have to continually click “Allow this application.” Now they just do it once and Twitter API Library will auto-magically log them in next time.
- Added bool $tw->if_is_user( int $user_id ) which returns true if the current user is the same as the inserted ID, and false if they aren’t.
Known Issues:
- No Support for Unauthenticated Requests.
- $tw->name() does not support users other than the currently logged in user.
- $tw->profile_pic() does not support users other than the currently logged in user.
- $twitter->get_sn_from_id() does not support users other than the currently logged in user.
- $twitter->get_name_from_id() does not support users other than the currently logged in user.
Twitter API Library – Build 5
URI: http://sandbox.gtaero.net/twitter_api/code.php?b=5 (Preview Level Code)
Change Log:
- Added string $twitter->get_sn_from_id(int $uid)
- Added string $twitter->get_name_from_id(int $uid)
- Added string $tw->profile_pic( [ int $uid = NULL [, array $options = NULL ] ] )
Options:- bool linked = true – Link to the User’s Profile
- string size = thumb (of small, thumb, large, or full) – Base Size of the Image
- int height = Size’s Default – Height in Pixels
- int width = Size’s Default – Width in Pixels
Known Issues:
- No Support for Unauthenticated Requests.
- $tw->name() does not support users other than the currently logged in user.
- $tw->profile_pic() does not support users other than the currently logged in user.
- $twitter->get_sn_from_id() does not support users other than the currently logged in user.
- $twitter->get_name_from_id() does not support users other than the currently logged in user.
Twitter API Library – Build 4
I’m going to post status updates on the Twitter API Library, despite the fact that I don’t think anyone is using it yet. I’ll post Change Logs to the blog.
URI: http://sandbox.gtaero.net/twitter_api/code.php?b=4 (Preview level Code)
- Addition of Read-Only “Quick Variables” for easy access.
- $twitter->uid – Logged In User’s ID.
- $twitter->name – Logged In User’s Full Name.
- $twitter->screen_name – Logged In User’s Screen Name.
- $twitter->first_name – Logged In User’s First Name (generated).
- $twitter->last_name – Logged In User’s Last Name (generated).
- Changes to $twitter->require_login() process (happens once per session):
- $twitter->require_login() is called.
- OAuth Data is Gathered from Twitter’s Server.
- User is Redirected to Twitter OAuth Authorization Page.
- OAuth Redirects User to Call Back Page (which should include or BE Twitter.php)
- Twitter API Library automatically redirects to page that called require_login() with OAuth Token
- $twitter->require_login() is called.
- OAuth Authorized Tokens are Stored and page is refreshed automatically without the OAuth Token in the URI.
- Authorization Tokens can then be called for storage using
list($token_key,$token_secret) = $twitter->get_login(). - If Authorization Tokens have been stored, entire process can be skipped using $twitter->use_login($token_key,$token_secret);
- Authorization Tokens can then be called for storage using
- $twitter->api->account_verifyCredentials() is called and the result is cached.
- Quick Variables are created.
- First Preview of “TWML” or Twitter Markup Language.
- TWML should be called with $tw = new TWML($twitter);
- Created Tag: $tw->name([ int $uid = NULL [, array $options ] ] )
Supported Options:- linked = true (link to profile)
- useyou = true (display “you” instead of name if logged in user)
- firstnameonly = false (only display first name)
- lastnameonly = false (only display last name (if available, else first))
- screennameonly = false (only display screen name)
- possessive = false (use possessive case, e.g. “your”)
- reflexive = false (use reflexive case, e.g. “yourself”)
- capitalize = false (capitalize if not a name, e.g. “Your”)
- subjectid = NULL
- Added $twitter->api->call_amount() which returns the amount of requests made to twitter (this instance).
Known Issues:
- No Support for Unauthenticated Requests
- $tw->name() does not support users other than the currently logged in user.
Twitter PHP Library
Well, being a PHP developer I quickly got excessively tired of looking for the proper Twitter Library with all the features that returned good results, and I got tired of looking for proper libraries and classes that could interface with OAuth.
Then, I found a relatively new (albeit “Beta”) Twitter OAuth Library, but it still required more steps than I really wanted to do just to get user authentication in a program. So I decided to finally piece everything together and write Twitter API Library.
This library basically does everything you would expect it to do, except for Unauthenticated Requests and the Search API… I haven’t gotten around to coding that in yet, as it was not the primary focus of this library.
The library is not thoroughly tested, but theoretically shouldn’t encounter any errors. I would be very grateful to anyone who’ll test it for me. (I can’t work out the bugs without testers, so please, test!).
Old Code – class::Scrobbler
A long time ago I wrote some PHP code for the AudioScrobbler API. I wrote it as more of a proof-of-concept and never touched it again, so I don’t know how well it works. I may play around with it some more as part of a test just to make sure the thing still works, but I wanted to share my code with you.
Source available at codepad and continued after the break.
Small Update: class::mp3Data v0.2
I just wanted to publish a small blog post letting you know that I have updated the mp3Data class to version 0.2.
Change log:
- Added function getArts() to retrieve ALL artwork embedded in ID3v2. These function returns an ordered array of PHP Image Resources.
Hope that if you use it, you enjoy the small change (not that it will be useful to many people)!
Code is located at pastebin and retains the same usage permissions as v0.1.
PHP class mp3Data – Get ID3 Info from MP3
So recently, I submitted a bid on a project to make a lyrics website using PHP. I haven’t been contacted about whether or not I won the bid yet, but I decided that I might as well start some preliminary work on backend coding – It’ll make my life easier, and deliver a faster and better result to the client, so why not?
Why am I mentioning this, you ask? What does my personal life have to do with my tech blog? Well, I’m getting to that!
I almost immediately thought. “Hey, wouldn’t it be really cool if the admin of the website could simply upload an MP3 file and pull almost, if not all of the data from it to use on the site?” After which, I quickly searched around for something that would allow me to do just that, to read the ID3 tags on an MP3 file.
The first thing I came to, was the search result on the PHP website for “id3,” the ID3 PECL Library. Unfortunately, after trying for a very long time on DreamHost, I not only couldn’t get it to install, but had just wasted probably an hour in an attempt to. Not only that, but the library was still in its alpha stage.
Some quick internet searching took me to the getid3 library, a robust library programmed to read ID3 data tags (and other types of metadata?) from almost any type of file. I quickly set about to using it, and found its internal structure complicated and confusing. It didn’t even offer me a quick and easy way to access the album artwork.
After a good period of time learning some of the basic structure of ID3 and how the getid3 library worked, I set about to coding up a library of my own to quickly interface with getid3 and retrieve the information I needed.
The result is class::mp3Data. A very, very simple library built exclusively to interface with getid3 and retrieve basic information about an mp3 file while still retaining more advanced information for coders who need it. Take a look at some example code and the licensing permissions after the break.
