REMOTE

?php /** * Returns a URL that grants access to vLex without explicitly signing in * * @since Unknown * * @param array $data : * Containing * [“external_id”]: SECRETARIA_CGS_ALBACETE * [“account_id”]: 1158448733 * [“token”] QAaaMNkwHSJ3lfURw6TKT91SlQS7TJbb4CO7yhK5YkmBgRRF * @return string : The URL granting access to vLex or NULL when errors occur */ function remote_auth($data) { // $data = {external_id => “SECRETARIA_CGS_ALBACETE”, account_id => “1158448733”, token ; “QAaaMNkwHSJ3lfURw6TKT91SlQS7TJbb4CO7yhK5YkmBgRRF”}
// Set default remote authorization path
$REMOTE_AUTH_URL = “http://vlex.com/session/remote_auth”;

// Sort $data checking that required parameters are present
$keys = array(“external_id”, “account_id”, “token”);
foreach($keys as $key) {
if(!isset($data[$key])) throw new Exception(“Missing parameter: $key”);
$values[$key] = $data[$key];
}

// Add timestamp
$values[“timestamp”] = time();

// Add hash from the concatenated data
$values[“hash”] = md5(implode($values));

// delete token
unset($values[“token”]);

// Generate the query and return the URL
$query = http_build_query($values); // name=yourname&email=…
return “$REMOTE_AUTH_URL?$query”;

// http://vlex.com/session/remote_auth?external_id=SECRETARIA_CGS_ALBACETE&account_id=1158448733&timestamp=918237192837&hash=akdka32yaskd3r
}

$datos = {external_id = $__SESSION_WP, account => “21937123”, token => “askdhaksd”}
remote_auth($datos)

/* Example
$my_data = array(“account_id” => “1234”, “token” => “TOKEN”, “external_id” => “id1234”);
$single_sing_on = remote_auth($my_data);
*/
header(“Location: “.$single_sing_on);

?>

A %d blogueros les gusta esto: