Created
March 18, 2011 08:42
-
-
Save ptz0n/875781 to your computer and use it in GitHub Desktop.
Tågtider API - Example Request
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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); | |
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