duanhoupeng6642 2014-04-08 18:51
浏览 23
已采纳

如何使用Janrain basic获取用户的电子邮件地址

I'm trying to get users email addresses when they log in so I can they can be entered into my database and given a unique ID. I've managed to retrieve user display names and store them in the database using this code however its not working with the email address.

session_start();
            if(property_exists($profile->profile,'displayName')){
                $_SESSION['username'] = $profile->profile->displayName;
                $_SESSION['email'] = $profile->profile->email;
                $_SESSION['logged']="logged";

                $username = $_SESSION['username'];
                $email = $_SESSION['email'];

                require_once("db_connect.php");
                $query="SELECT email FROM users WHERE email = '$email'";
                mysqli_select_db($db_server, $db_database);
                $result=mysqli_query($db_server, $query);
                if($result != $email){
                    $query = "INSERT INTO users (username, email) VALUES ('$username', '$email')";
                    mysqli_query($db_server, $query) or
                                die("Insert failed. ". mysqli_error($db_server));
                }else{
                    echo "Login error.";    
                }

                mysqli_free_result($result);
                require_once("db_close.php");
                header('location:home.php');
            }else{
                $_SESSION['username'] = '(Anonymous)';
                $_SESSION['logged']="logged";
                header('location:home.php');
          } 

Thanks for your help.

  • 写回答

1条回答 默认 最新

  • duancui19840401 2014-04-13 00:17
    关注

    It sounds like it has to do with what information the providers share by default. I believe these steps should fix it:

    1. Log in to https://dashboard.janrain.com/
    2. Select your Engage application
    3. In the "Providers" box, hover over the one that you are trying to authenticate with
    4. Click the small wrench icon that appears after you've hovered over the provider
    5. Make sure that the "Ask" box is checked next to "email"

    Let me know if that works out for you!

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 软件测试决策法疑问求解答
  • ¥15 win11 23H2删除推荐的项目,支持注册表等
  • ¥15 matlab 用yalmip搭建模型,cplex求解,线性化处理的方法
  • ¥15 qt6.6.3 基于百度云的语音识别 不会改
  • ¥15 关于#目标检测#的问题:大概就是类似后台自动检测某下架商品的库存,在他监测到该商品上架并且可以购买的瞬间点击立即购买下单
  • ¥15 神经网络怎么把隐含层变量融合到损失函数中?
  • ¥15 lingo18勾选global solver求解使用的算法
  • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行
  • ¥20 测距传感器数据手册i2c
  • ¥15 RPA正常跑,cmd输入cookies跑不出来