Skip to content

Instantly share code, notes, and snippets.

@fasmide
Created November 9, 2011 12:37
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fasmide/1351313 to your computer and use it in GitHub Desktop.
Save fasmide/1351313 to your computer and use it in GitHub Desktop.
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
)));
@satvug
Copy link

satvug commented Sep 11, 2019

Does this still work? It just hangs for me when I try to access any address on api.dba.dk, even when supplying android/iPhone useragents

@fasmide
Copy link
Author

fasmide commented Sep 11, 2019 via email

@lmunck
Copy link

lmunck commented Sep 23, 2021

@lmunck
Copy link

lmunck commented Sep 23, 2021

Looks a bit more advanced now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment