Everyone loves Music and i’m sure that everyone has searched for a lyric of a song before. Right? Right. So why not build a lyric search for your own website? Too complicated? No way. I show you how you can build your own Music Search Engine with less than 20 lines of code – using the API of the awesome Lyricwiki.org Website. With these few lines you can search for over 680.000 Lyrics. So lets go – here is the code:
The Code…
$artist = $_GET["artist"]; //get your artist $song = $_GET["song"]; //get your song $artist = str_replace(" ", "_", $artist); //Replace spaces with_ $song = str_replace(" ", "_", $song); //Replace spaces with_
<!--Now a simple HTML Form with artist and song fields --> <form action="<?php $_SERVER["PHP_SELF"];?>" method="get"> <label for="artist">Artist:</label> <input type="text" name="artist" value="<?php echo $artist;?>" id="artist" /> <label for="song">Songname:</label> <input type="text" name="song" value="<?php echo $song;?>" id="song"/> <input type="submit" value="search"/> </form>
// The important part-get the Lyric from the Lyricwiki.org API $info = file_get_contents("http://lyricwiki.org/api.php?artist=".$artist."&song=".$song."&fmt=text"); echo nl2br($info); //echo our searched lyrics
Example
Check out the Example of this script. If you just enter an Artist and no Song name, all songs of the found Artist will be displayed! Cool stuff!
Download the Code
Grab this script and use it as you want – a backlink to kollermedia.at would be awesome of course 🙂
Music Lyric Search Engine (703 bytes, 2.029 hits)
Pat schreibt:
I was looking for something like this! This is perfect. Thanks so much!
James schreibt:
I was looking for an example of how to implement the api at lyricwiki and this looks great except that when I try to search a song name nothing comes up. Was there an update on the lyricwiki api which disallows this implementation?
Also I tried searching for a recent artist and nothing comes up but when you search on the lyricwiki website it comes up. I don’t really know why this is happening.
If you could help me with implementing the api it would be greatly appreciated.
Thank you,
James
Webdawson schreibt:
Hi James,
it still does work.
Just try Mariah Carey and click search.
Or try Mariah Carey and Alone in Love
If you search for a Song you always have to enter an artist & the song name.
Pet schreibt:
Hi!
Ich habe dieses Script für meine Webseite benutzt. Leider habe ich festgestellt, dass sie nicht mehr funktioniert.
Anscheinend hat Wiki änderungen vorgenommen.
Könntest Du mir bitte sagen was ich jetzt ändern muss?
Ich habe sehr wenig erfahrung mit Scripting! (Newbee :()
Ich danke Dir im voraus.
Webdawson schreibt:
Hi, ja du hast recht leider wurde dort die API verändert – man bekommt von dort jetzt leider keine lyrics mehr – also helfen auch Änderungen am code leider nichts.
Pet schreibt:
Tja, dann ist es dumm gelaufen.
Auf jeden fall, möchte ich mich für deine tolle Beiträge bedanken.
LG. Pet
sandrar schreibt:
Hi! I was surfing and found your blog post… nice! I love your blog. 🙂 Cheers! Sandra. R.
Webnessie schreibt:
hallo,
gibt es ein update für das script ?
vielen dank im voraus
??????????????????? schreibt:
Thank for your best code
games schreibt:
Thanks
comsgzmpjm schreibt:
YwcNqmowFRKyEUKZPkl Chanel Handbags Online Store CwsPGrk