Engwar

Chintana Wilamuna's weblog

Fetching song lyrics

LyricWiki is an excellent free service providing song lyrics. A la wikipedia for song lyrics. One cool feature is that the site uses nuSOAP to provide a web services interface for fetching lyrics. Wrote a small PHP class with the help of WSF/PHP which will give a simpler interface. Grab it here (make sure to rename it to .php).

Here’s a few method calls,

Getting song of the day should be easy. getSOTD() method returns an array, song title, artist and the lyrics. Let’s just fetch the song and display only the lyrics.

getSOTD();

print $song['lyrics'];
?>

Ok, let’s try to fetch lyrics of a song you know,

getSong('iron & wine', 'boy with a coin');

?>
  • http://lyricwiki.org Sean

    Hey! Awesome script :) Probably a bunch of ppl will find it helpful.

    … there was one small detail that might be nice to see different: since the site is named “LyricWiki” (the singluar “lyric” not plural “lyrics”), could the script possibly be changed to be LyricWiki instead of LyricsWiki.

  • http://engwar.com/ Chintana

    @Sean: Absolutely! Sorry for the typo, just corrected it.

  • Pingback: Fetching music from LyricWiki « nrdLabs

  • http://kevinlopez.mooo.com Kevin López

    You forgot to put the semicolon on “require ‘lyricwiki.php’”.

  • http://engwar.com/ Chintana

    @Kevin: doh, corrected. Thanks Kevin.

  • Andrea

    I Receive

    Fatal error: Class ‘WSClient’ not found

  • http://engwar.com/ Chintana

    @Andrea: You have to have WSF/PHP installed. Get it from here – http://wso2.org/projects/wsf/php. Holler if you have any trouble installing it.

  • http://www.getshawty.com Horace Vandermeer

    [...] Fetching song lyrics at Engwar – http://engwar.com/post/58http://www.GetShawty.com [...]

  • http://www.medidit.com Medidit

    It didn’t work the first time, but after I double checked it, I realized I was missing a );
    Ande, you might want to try again checking the code…it works awesome for me and it’s really worth it.
    Many thanks!