view examples/search/resultsSet.php @ 8:226f00d9f6f5

another error check
author Henry Thompson <ht@markup.co.uk>
date Fri, 17 Feb 2017 15:22:53 +0000
parents 077b0a0a3e6d
children
line wrap: on
line source

<?php
	class resultsSet {
		var $searchType;
		var $count;
		
		function __construct($type, $cnt) {		
			include_once('constants.php'); 
			$this->searchType = $type;
			$this->count = $cnt;			
		}		
			
		function getXMLResults($query){	
			$API = 'http://boss.yahooapis.com/ysearch/'.$this->searchType .'/v1/';
			$request = $API . $query .'?format=xml&appid='. APP_ID . '&count=' . $this->count ; 
			//echo $request;

			$ch = curl_init($request);
			curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
			curl_setopt($ch, CURLOPT_HEADER, 0);
			$output = curl_exec($ch);
			curl_close($ch);
			//echo $output;
			$xml = simplexml_load_string ($output);
			return $xml;
		}
		
	}