Skip to content

Instantly share code, notes, and snippets.

@blar
Created August 5, 2012 16:38
Show Gist options
  • Select an option

  • Save blar/3265821 to your computer and use it in GitHub Desktop.

Select an option

Save blar/3265821 to your computer and use it in GitHub Desktop.
Lokalisierung von IP-Adressen mit der API der Telekom
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_RETURNTRANSFER => true,
CURLOPT_URL => 'https://sts.idm.telekom.com/rest-v1/tokens/odg',
CURLOPT_HTTPAUTH => CURLAUTH_BASIC,
CURLOPT_USERPWD => ''
));
$response = json_decode(curl_exec($curl));
curl_close($curl);
$token = $response->token;
$query = http_build_query(array(
'ipaddress' => ''
));
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_RETURNTRANSFER => true,
CURLOPT_URL => 'https://gateway.developer.telekom.com/plone/iplocation/rest/sandbox/location?'.$query,
CURLOPT_HTTPHEADER => array(
'Accept: application/json',
'Authorization: TAuth realm="https://odg.t-online.de",tauth_token="'.$token.'"',
)
));
$response = json_decode(curl_exec($curl));
curl_close($curl);
var_dump($response);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment