Simpel kommunikation med DBA's api
<? | |
class DBA { | |
/** | |
example params: | |
'q' => 'yamaha mixer', | |
'ps' => 20, | |
'pn' => 1, | |
'f' => 'json', | |
'filters' => 1 | |
*/ | |
public static function search($params) | |
{ | |
$query = http_build_query($params); | |
$ch = curl_init('http://api.dba.dk/public/v1/ads?'.$query); | |
curl_setopt_array($ch, array( | |
CURLOPT_USERAGENT => 'Mozilla/5.0 (Linux; U; Android 2.2.1; en-US; X2 Build/FRG83) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1 (Agoraphobia)', | |
CURLOPT_RETURNTRANSFER => true | |
)); | |
$response = curl_exec($ch); | |
curl_close($ch); | |
return json_decode($response); | |
} | |
} | |
echo json_encode(DBA::search(array( | |
'q' => "galaxy s wifi", | |
'ps' => 20, | |
'pn' => 1, | |
'f' => 'json', | |
'filters' => 1 | |
))); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment