Created
November 9, 2011 12:37
-
-
Save fasmide/1351313 to your computer and use it in GitHub Desktop.
Simpel kommunikation med DBA's api
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
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
Looks a bit more advanced now