Skip to content

Instantly share code, notes, and snippets.

@fasmide fasmide/dba.php
Created Nov 9, 2011

Embed
What would you like to do?
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

This comment has been minimized.

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

This comment has been minimized.

Copy link
Owner Author

fasmide commented Sep 11, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.