Twitter 1.1 API  Startup and Play LoginI was hoping when I started to rebuild the Startup and Play project to be able to grab a quick Twitter OAuth plugin that would allow users to register for the site. I found a plugin, specifically Nextend Twitter Connect, installed it and created my application on the developers site. It works! I was able to login but a few things were broken, one somewhat important feature – profile images.

No big deal, I’ll just go ahead and fix it. Immediately I see that the author had been active as recent as June, but with issues piling up in the support section I decided to just call it my own. With that I have also gone ahead and added extra field completion including the users twitter handle, description, modern styles, and font-awesome icons. Currently it is available on GitHub though the styles are being refactored and should be complete by the end of the week.

Version 1.0 of the Twitter API did not require you the authenticate in the same way 1.1 does, it also utilized a different method for grabbing a users profile image. This is the original code from the plugin.

That responds with a blank page. After reading the support forum one user suggested this.

While that works, it only retrieves us a 48x48px image. Not quite what I need for the site. What I really need is the original size user image, via https, to allow myself to make changes from there.

Here is what I’ve come up with so far. This code snippet will function for jpg/jpeg/png as I found my old code broke when users had set either a jpeg or jpg as their profile image.

While I left my code comments in the snippet, simply put, the https url is called, we figure out the extension of the file, delete either 11 or 12 characters from the end. The 11 or 12 characters removes the _normal.png or _normal.jpeg for example, then we reattach the file extension and update the user meta property for profile image. Still working on redoing the CSS styles for the plugin, but it is available on GitHub at https://github.com/patrickshampine/wpps-twitter-connect.