Display and Link Your YouTube Favorites in a WordPress Widget
20. April 2010 - 01:38 UhrOne of the goals of my blog’s reanimation was to link as many of all my different channels spread all over the web (slogan: “You host, I aggregate”) to this site. Thus I wanted a widget that displays and links my recent favorite YouTube videos in a WordPress widget. I couldn’t find one that still worked and since I had wanted to find out how coding a WordPress widget feels for quite some time I decided to write one. Second, I had never messed with the YouTube API before. Turns out, both were drop dead simple and after two hours of fiddling around I finished the YouTubeFavorites WordPress Widget. I used SimplePie as a library to parse the ATOM favorite feed of the Google Data API. Thanks, guys! (Also for saving our lives on some project from hell last year…)
The steps to add the widget to your WordPress (2.8+) installation:
- Get yourself a Google YouTube developer key at http://code.google.com/apis/youtube/dashboard/. There’s no way to fetch a list of your favorite videos without a dev key.
- Download the YouTubeFavorites source zip.
- Unpack the contents into your WP_HOME/wp-content/plugins/widgets folder.
- Create a ‘cache’ folder for SimplePie inside the ‘widgets’ folder, make it writeable (‘chmod 755 cache’, depending on your hoster it might be 777). Adjust the SIMPLEPIE_CACHE constant in YouTubeFavorites.php to point to the cache directory.
- Activate the widget in WordPress’s plugin section.
- Change to the Widget set up section and drag the widget to your sidebar.
- Enter your YouTube user name, your developer key from step 1 and the number of entries to show.
- Check your blog. You’re done.
