I use the API provided by flipkart.com, this allows me to search and retrieve results as json .
The code I use is:
$snapword = $_GET['p']; $snapword = str_replace(' ','+',$snapword); $headers = array( 'Fk-Affiliate-Id: myaffid', 'Fk-Affiliate-Token: c0f74c4esometokesndad68f50666' ); $pattern = "@\(.*?\)@"; $snapword = preg_replace($pattern,'',$snapword); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'https://affiliate-api.flipkart.net/affiliate/search/json?query='.$snapword.'&resultCount=5'); curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); curl_setopt($ch, CURLOPT_ENCODING , "gzip"); curl_setopt($ch, CURLOPT_USERAGENT,'php'); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); $snapdeal = curl_exec($ch); curl_close($ch); $time_end = microtime(true); $time = $time_end - $time_start; echo "Process Time: {$time}";
and the time it takes: Process Time: 5.3794288635254
What too much, any ideas on how to reduce this?
source share