Skip to content

Instantly share code, notes, and snippets.

@iwek
Last active April 1, 2020 15:03
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iwek/5117244 to your computer and use it in GitHub Desktop.
Save iwek/5117244 to your computer and use it in GitHub Desktop.
PHP Curl call to get a Traceroute with Pingdom API
<?php
//initialize
$ch = curl_init();
// 2. set the options, including the url
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_URL, "https://api.pingdom.com/api/2.0/traceroute?host=techslides.com");
curl_setopt($ch, CURLOPT_USERPWD, "EMAIL:PASSWORD");
curl_setopt($ch, CURLOPT_HTTPHEADER, array("App-Key: YOUR-KEY-HERE"));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
//execute
$output = curl_exec($ch);
if ($output === FALSE) {
echo "cURL Error: " . curl_error($ch);
} else {
$response = json_decode($output,true);
echo $response['traceroute']['result'];
}
//free up the curl handle
curl_close($ch);
?>
@iwek
Copy link
Author

iwek commented Mar 8, 2013

An improved version is here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment