Question
-
You can use their API Explorer to see what's available in terms of the API. It's pretty neat and serves as nice documentation, just look at the REST style URLs.
Here's basic code to get the last 5 checkins. You will need an API Key.
$username = 'sco'; $api_key = 'f6cd524ac9c4413abfb41d7123757d9'; $checkin_num = 5; $url = "http://api.gowalla.com/users/{$username}/stamps?limit={$checkin_num}"; // setup curl $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HTTPHEADER, array ( "Accept: application/json", "X-Gowalla-API-Key: {$api_key}", )); $body = curl_exec($ch); curl_close($ch); $json = json_decode($body, true); foreach($json['stamps'] as $stamp) { print $stamp['spot']['name'] . '<br/>'; print "<pre>"; print_r($stamp); print "</pre>"; }Here's what a checkin
'stamp'object looks like:
Answer byArray ( [spot] => Array ( [image_url] => http://static.gowalla.com/categories/24-standard.png [url] => /spots/19890 [lat] => 38.9989524833 [address] => Array ( [locality] => Kansas City [region] => MO ) [lng] => -94.5939345333 [name] => The GAF Pub & Grille ) [first_checkin_at] => 2010-06-12T19:16:57+00:00 [checkins_count] => 1 [last_checkin_at] => 2010-06-12T19:16:57+00:00 )
artlung