public
Created

Tågtider API - Example Request

  • Download Gist
example.php
PHP
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
<!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));

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.