I've setup Janrain social login. The only thing left is to make it more of a personalized message when logging in using this. I have no experience with php at all. It's just a practice or demo page at https://www.ntademo.com/ where you can use social login through google+ or facebook.
Here's the very top of what's returned. What'd i'd like to do is return a friendly message when someone logs in using google+ or facebook. Thank you for any input on what I should do next.
Here's a php script called rpx-token-url.php
<?php
if ($token) {
// Step 2: Use the token to make the auth_info API call.
$post_data = array(
'token' => $token,
'apiKey' => $janrain_api_key,
'format' => 'json'
);
'apiKey' => $janrain_api_key,
'format' => 'json'
);
if ($social_login_pro) {
$post_data['extended'] = 'true'; }
$curl = curl_init();
$url = 'https://rpxnow.com/api/v2/auth_info';
$result = curl_helper_post($curl, $url, $post_data);
if ($result == false) {
curl_helper_error($curl, $url, $post_data);
die();
}
curl_close($curl); if ($auth_info['stat'] == 'ok') {
echo "\n auth_info:";
echo "\n"; var_dump($auth_info);
if ($social_login_pro) {
include('social_login_pro_examples.php');
}
} else {
// Handle the auth_info error.
output('An error occurred', $auth_info);
output('result', $result);
} } else {
echo 'No authentication token.'; } $debug_out = ob_get_contents(); ob_end_clean(); ?> <head>
<title>Janrain Token URL Example</title>
</head>
<body>
<pre><?php echo $debug_out; ?></pre>
</body> </html>
auth_info:
array(4) {
["stat"]=>
string(2) "ok"
["profile"]=>
array(7) {
["providerName"]=>
string(7) "Google+"
["identifier"]=>
string(53) "https://www.google.com/profiles/xxxxxxxxxxxx"
["displayName"]=>
string(16) "My Name"
["name"]=>
array(3) {
["formatted"]=>
string(16) "My Name"
["givenName"]=>
string(4) "Mt"
["familyName"]=>
string(11) "Name"
}
["photo"]=>
string(99) "https://lh3.googleusercontent.com/-XdUIqdMkCWA/AAAAAAAAAAI/AAAAAAAAAAA/4252rscbv5M/photo.jpg?sz=400"
["googleUserId"]=>
string(21) "xxxxxxxxx"
["providerSpecifier"]=>
string(10) "googleplus"
}
["merged_poco"]=>
array(5) {
["id"]=>
string(21) "xxxxxxxxxxx"
["displayName"]=>
string(16) "My Name"
["name"]=>
array(3) {
["formatted"]=>
string(16) "My Name"
["givenName"]=>
string(4) "My"
["familyName"]=>
string(11) "Name"
}
["languagesSpoken"]=>
array(1) {
[0]=>
string(2) "en"
}
["photos"]=>
array(1) {
[0]=>
array(2) {
["value"]=>
string(99) "https://lh3.googleusercontent.com/-XdUIqdMkCWA/AAAAAAAAAAI/AAAAAAAAAAA/4252rscbv5M/photo.jpg?sz=400"
["type"]=>
string(5) "other"
}
}
}
["accessCredentials"]=>
array(7) {
["accessToken"]=>
string(71) "ya29.Ci-vAwW_RMSVgS9r_VCFp1JySU5dz0UoqVCgwmej3-UTUQnW8NzkLP7qDgk9N4zzxA"
["uid"]=>
string(21) "117971470422940045510"
["expires"]=>
int(1481265328)
["refreshToken"]=>
string(45) "1/JkuvkZkq060wASEY2DGUtko_AkCc_-xdyiFQFhF0PiQ"
["scopes"]=>
string(7) "profile"
["clientId"]=>
string(72) "407531817131-okq2ahfvs8ggkpmgvt6a31udmnahqemj.apps.googleusercontent.com"
["type"]=>
string(6) "oauth2"
}
}
How about replacing:
<pre><?php echo $debug_out; ?></pre>
with:
<pre><?php
if(isset($auth_info) && $auth_info['stat'] == 'ok')
echo('Hello '.$auth_info['merged_poco']['displayName'].' thanks for logging in');
else
echo('Please log in'); ?>
</pre>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.