Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Janrain error: Undefined index: token

$
0
0
Hello I'm trying to redirect the user to a page to print out the user name with a hello statement with the use of janrain and I keep getting this error:
Notice: Undefined index: token in /var/www/vhosts/numyspace.co.uk/web_users/home/~unn_w10011815/public_html/emergingweb/page01.php on line 8

this is the code for the page the rpx.php:


<?php
header('Content-type: text/json');

$token = $_POST['token'];
require 'apiKey.php';

$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, 'https://rpxnow.com/api/v2/auth_info');
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS,
array('token' => $token,
'apiKey' => $apiKey));
curl_setopt($curl, CURLOPT_FAILonerror, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($curl);
if (!$response){
echo '{"Curl error": "' . curl_error($curl). '",';
echo '"HTTP code": "' . curl_errno($curl) . '"}';
} else {
echo $response;
}
curl_close($curl);
$redirect='http://numyspace.co.uk/~unn_w10011815/emergingweb/page01.php';
header('Location: '.$redirect);
?>


and this is where the error occurs
<html>
<head>
<title>Example Application Landing Page</title>
</head>
<body>
<h1>Example Application Landing Page</h1>
<?php
$token = $_POST['token']; //line 8 this is where the error occurs
require 'apiKey.php';

$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, 'https://rpxnow.com/api/v2/auth_info');
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS,
array('token' => $token,
'apiKey' => $apiKey));
curl_setopt($curl, CURLOPT_FAILonerror, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$profileString = curl_exec($curl);
if (!$profileString){
echo '<p>Curl error: ' . curl_error($curl);
echo '<p>HTTP code: ' . curl_errno($curl);
} else {
$profile = json_decode($profileString);
if (property_exists($profile, 'err')) {
echo '<p>Engage error: ' . $profile->err->msg;
} else {
session_start();
if (property_exists($profile->profile, 'displayName')) {
$_SESSION['userName'] = $profile->profile->displayName;
} else {
$_SESSION['userName'] = '(Anonymous Coward)';
}
echo '<p>Hi there ' . $_SESSION['userName'] . '!';
}

}
curl_close($curl);
?>
</body>
</html>



The code works (when i use it through Janrain's own testing page), however it doesn't work when I try it live on my site.

if anyone can help please get in touch
Regards
Bestford

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>