Skip to content

Instantly share code, notes, and snippets.

@steffentchr
Created December 15, 2016 23:04
Show Gist options
  • Save steffentchr/3dc4e19d4514d35a76cef717302866a2 to your computer and use it in GitHub Desktop.
Save steffentchr/3dc4e19d4514d35a76cef717302866a2 to your computer and use it in GitHub Desktop.
<?php
require_once('visualvideo.php');
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Content-Type: application/javascript");
function getSessionToken($returnUrl, $name, $email) {
// Fix: The client should be loaded as a global outside of the function
// Note: This required use of privileged credentials with the API
$client = new VisualVideo('http://mydomain.23video.com',
$consumerKey,
$consumerSecret,
$accessToken,
$accessTokenSecret);
// Fix: A bit of extra error handling here would be good
$response = json_decode($client->get('/api/session/get-token', array('return_url' => $returnUrl, 'email' => $email, 'full_name' => $name, 'format' => 'json', 'raw' => 1)), true);
return($response['sessiontoken']['access_token']);
}
function redirectSessionToken($sessionToken) {
$url = 'http://reference.dev.visualtube.net/api/session/redeem-token?session_token=' . $sessionToken;
Header('Location: ' .$url);
}
if( array_key_exists('return_url', $_GET) && $_GET['return_url'] != "") {
$returnUrl = $_GET['return_url'];
} else {
$returnUrl = '/';
}
// Fix: If at all possible, include name + email address here. This will enable People tracking
redirectSessionToken(getSessionToken($returnUrl, '', ''));
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment