$query, 'media' => $type, 'limit' => $limit, ); //for testing purposes show actual request to API - REMOVE when finished $apiRequest = $base.http_build_query($params); echo $apiRequest; //build request, encode entities (using http_build_query), and send to API $request = file_get_contents($base.http_build_query($params)); //create json object(s) out of response from API $data = json_decode($request); //parse json elements and display as html if ($data->resultCount != 0) { echo '

Results of your search for '.$query.' (Showing first '.$limit.' matches)

'."\n"; echo '
    '."\n"; foreach ($data->results as $item) { //check to make sure short summary is available - set default message if it is not if (strlen($item->summary_short) < 2) { $summary = 'Short summary not available.'; } else { $summary = $item->summary_short; } echo '

  1. '.$item->collectionName.' '.$item->artistName.'
    '.$summary.'
    ID: '.$item->artistId.'
    Date: '.$item->releaseDate.'.
    Price: '.$item->collectionPrice.'
    Format: '.$item->wrapperType.'
  2. '."\n"; } echo '
'."\n"; echo '

Reset the page

'."\n"; } else { echo '

No results for '.$query.'.

'."\n"; echo '

Reset the page

'."\n"; } ?>