1 Replies - 406 Views - Last Post: 27 January 2013 - 07:33 PM Rate Topic: -----

#1 Bestford  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 44
  • Joined: 05-December 11

Janrain error: Undefined index: token

Posted 27 January 2013 - 07:08 PM

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

Is This A Good Question/Topic? 0
  • +

Replies To: Janrain error: Undefined index: token

#2 Sho Ke  Icon User is online

  • D.I.C Head
  • member icon

Reputation: 107
  • View blog
  • Posts: 246
  • Joined: 13-October 11

Re: Janrain error: Undefined index: token

Posted 27 January 2013 - 07:33 PM

That means $_POST['token'] is undefined. Try var_dump ing $_POST.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1