Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Creating a search field to search API.

Featured Replies

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.

  • Author

I'm slowly moving down the forums here. Anyone able to help me?

 

Sorry for the bump.

I'll take a look later on and rough up some php script if nobody else will

  • 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.

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.

  • 2 months later...
  • 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

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.