Created
August 5, 2012 16:38
-
-
Save blar/3265821 to your computer and use it in GitHub Desktop.
Lokalisierung von IP-Adressen mit der API der Telekom
This file contains hidden or 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
| <?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