require_once '../library/engage.auth.lib.php'; $debug_array = array('Debug out:'); /** * For a production script it would be better * to include (require_once) the apiKey in * from a file outside the web root to * enhance security. * * Set your API key (secret) in this file. * The varable is $api_key */ require_once 'engage-conf.php'; $token = $_POST['token']; $format = ENGAGE_FORMAT_JSON; $extended = $auth_info_extended; $result = engage_auth_info($api_key, $token, $format, $extended); if ($result === false) { $errors = engage_get_errors(); foreach ($errors as $error => $label) { $debug_array[] = 'Error: ' . $error; } } else { /** * On a successful authentication store * the auth_info data in the variable * $auth_info_array */ $array_out = true; $auth_info_array = engage_parse_result($result, $format, $array_out); //Put a printed copy in the debug. $debug_array[] = print_r($auth_info_array, true);
} $clean = true; reset($actions); while (list($action, $vals) = each($actions)) { if ($vals['do'] === true) { $actions[$action]['do'] = false; switch ($action) { case 'auth_info': $extended = false; if ($vals['extended'] == 'true') { $extended = true; } if ($vals['api_key'] == $forty_stars && ENGAGE_CONSOLE_API_KEY != '') { $vals['api_key'] = ENGAGE_CONSOLE_API_KEY; } $result = engage_auth_info($vals['api_key'], $vals['token'], $vals['format'], $extended); if ($result === false) { $clean = false; } else { $actions['parse_result'] = array('result' => $result, 'format' => $vals['format'], 'export' => array('identifier' => array('profile', 'identifier')), 'do' => true); if ($vals['format'] == 'json') { $actions['indent_json'] = array('json' => $result, 'do' => true); } if ($vals['format'] == 'xml') { $actions['indent_xml'] = array('xml' => $result, 'do' => true); } } break; case 'parse_result': $parse_result = engage_parse_result($vals['result'], $vals['format']); if ($parse_result === false) {