Skip to content

Instantly share code, notes, and snippets.

@bsullins
Last active August 29, 2015 14:26
Show Gist options
  • Select an option

  • Save bsullins/5bbc3075ee74b681640b to your computer and use it in GitHub Desktop.

Select an option

Save bsullins/5bbc3075ee74b681640b to your computer and use it in GitHub Desktop.
Embedding Metric Insights PHP sample
<?php
define('BASE_URL','https://metrics.pluralsight.com');
define('APPLICATION_ID','...');
define('APPLICATION_KEY','...');
$ch = curl_init(BASE_URL.'api/get_ticket/');
curl_setopt($ch, CURLOPT_POSTFIELDS, array('application_id'=>APPLICATION_ID,
'application_key'=>APPLICATION_KEY,
'user'=>'bsullins'));
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept: application/json'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($ch);
$tmp = json_decode($response, true);
$ticket = $tmp['ticket'];
printf($tmp);
echo(BASE_URL.'ticket/'.$ticket.'/'.(isset($_GET['url'])?$_GET['url']:''));
//header('Location: '.BASE_URL.'ticket/'.$ticket.'/'.(isset($_GET['url'])?$_GET['url']:''),true,302);
exit;
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment