Muschamp Rd

albumCollection.php worked

October 6th, 2010
CD covers

I never set out to write this much PHP code. But after seeing what passes for a PHP API to access Amazon Product Information, well I vowed to do a good job on my PHP class, even though it was intended for my own personal use. I had modest goals at the beginning I just wanted to take a list of CDs I own and produce a gallery of album covers.

Update: I ended up writing far too much PHP code and creating a series of web mashups, the code for which is detailed online. Alas now it is ten years later and the APIs have changed and I don’t know if I will ever or even I can legally implement all the features I had working before so I can not recommend you run out and download my code.

Look at all the pretty icons and buttons

The third API I got working was Facebook, although it too had buggy PHP code online claiming to solve all my needs. I ended up not using much of that code or the Facebook API, but I made a little button so you can like an artist following various official guidelines and my own trial and error. I also got pretty good at string manipulation and using CURL and JSON.

I was always going to integrate with iLike but their developer site was always down or the documentation was down, basically they were just holding me up and it’s not like I needed them. So I went on to the iTunes Music Store. The iTunes Music Store does have an API of sorts, you can search it and fetch back various links. They even have an affiliate program but it isn’t available in Canada. The only affiliate program I’ve implemented is the only one I’ve ever signed up for, Amazon Associate. I don’t really use my ID though, so for this project I put in support for that.

I really don’t use very much of any one API. I don’t even fetch that much data. Mainly I link out to more information, rather than pull it into my application. This is partially done for speed, but also because that was closer to my original design. Now that I’ve written so much PHP code I’ll probably make a couple uses of it.

Tweet this functionality in action

I added caching to my iTunes Music Store queries. I don’t query it that much and it’s not like the URL to an artist’s page is going to change very often. With basic iTunes functionality working today, I added in support for Twitter. Some people seem to love Twitter, so I implemented the Tweet This button. You can now Tweet your favourite albums from my collection, or at least this subset of my collection that I’m using for testing.

I’m still not the world’s biggest fan of PHP but it did become more object oriented eventually but it still has inconsistent naming. Some projects like WordPress have taken off but there is a lot of spotty PHP out there. I should have spent 2010 coding in JavaScript perhaps as I see more job postings for that, but I don’t understand why after passing all three CFA® exams and learning Python for data analysis I still cannot get a job. Maybe I’ll have to try fixing old PHP code but for now I’m just editing old blog posts and limiting the out of date and unprofessional content on my domain.

If you love PHP or have some useful code you want to share you can leave a comment below.

One Comment

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Posts on Muskblog © Andrew "Muskie" McKay.
CFA Institute does not endorse, promote or warrant the accuracy or quality of Muskblog. CFA® and Chartered Financial Analyst® are registered trademarks owned by CFA Institute.