Skip to content

Instantly share code, notes, and snippets.

@ptz0n
Created March 18, 2011 08:42
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 ptz0n/875781 to your computer and use it in GitHub Desktop.
Save ptz0n/875781 to your computer and use it in GitHub Desktop.
Tågtider API - Example Request
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<h1>Tågtider API - Exempel</h1>
<pre><?php
// Setup
$url = 'http://api.tagtider.net/v1/stations.json';
$key = 'tagtider';
$secret = 'codemocracy';
$options = array(
CURLOPT_FRESH_CONNECT => 1,
CURLOPT_URL => $url,
CURLOPT_USERAGENT => 'Tågtider Exempel',
CURLOPT_HTTPAUTH => CURLAUTH_DIGEST,
CURLOPT_USERPWD => $key . ":" . $secret,
CURLOPT_RETURNTRANSFER => 3,
);
// Handle and return
$session = curl_init();
curl_setopt_array($session, $options);
$response = curl_exec($session);
curl_close($session);
// Print
if($response)
print_r(json_decode($response));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment