November 14, 201115 yr Hello all. Hopefully someone can point me in the right direction here. I want to create a basic search field that searches XML data on another server via an API. More specifically what I want to do is have a user type in a specific artist or band that searches last.fm's geo.getEvents API. What's the best way to go around this? Is PHP the best language to use? I've searched a fair few tutorials online but none seem to fit this request. Many thanks for anyone that can give me a clue on this.
November 15, 201115 yr Author I'm slowly moving down the forums here. Anyone able to help me? Sorry for the bump.
November 15, 201115 yr Author Thanks for this, it's really appreciated - a gentle nudge in the right direction should get me started. It's part of my final major project for uni so I'm learning as I go along.
November 16, 201115 yr Aplogies delayed a bit this end on a job, haven't gone through all the lastFM documentation yet but here's a couple of pointers. Youn need to look at the artist.getEvents xml feed as this does exactly what you want all you have to do is give it an artists name and it returns a list of upcoming gigs and other information. In this case 'lady gaga' http://ws.audioscrobbler.com/2.0/?method=artist.getevents&artist=lady%20gaga&api_key=b25b959554ed76058ac220b7b2e0a026 As it's part of your final project we'll asume you have covered basic html input forms if not then Tizag.com may be worth a visit for a refresher tutorial. Once the user has provided a name then you need to build the query URL. I'll use php for this example as it's going to be useful later on. $first_bit_of_url = 'http://ws.audioscrobbler.com/2.0/?method=artist.getevents&artist='; $last_bit_of_url = '&api_key=b25b959554ed76058ac220b7b2e0a026'; $artist = ($_GET["artist"]); // gets the information passed by the input form $query_url = $first_bit_of_url . $artist . $last_bit_of_url ; $upcoming_gig_data_xml = simplexml_load_file($query_url); Now all you have to do is extract (technical term is 'parse') the pieces you want and there are plenty of tutorials like this one http://webhole.net/2009/07/25/how-to-parse-xml-with-php-part-one/ that will walk you through it.
February 12, 201214 yr Author Sogo7, I really appreciate your help with this problem. I'm slowly but surely becoming more comfortable with PHP because of this. I'm finally able to parse some information from last.fm's xml document. The only problem that I face now is I can't use distance or location parameters with artist.getEvents, only get.getEvents. How would I go about limiting this data to, for instance, Belfast? I understand it'll probably take someone with Last.fm experience to answer this question for me. Kudos to anyone that can help me with this. Chris.
Create an account or sign in to comment