【问题标题】:How to fetch user's First Name in php using Gmail Credentials as input?如何使用 Gmail 凭据作为输入在 php 中获取用户的名字?
【发布时间】:2015-02-27 19:04:50
【问题描述】:

我之前在 php 中使用 imap_open 函数从表单验证用户的凭据并让他们登录到我的网站。 现在我还想打印他们的名字,这些名字可以从谷歌服务器中获取,提供他们的凭据作为输入。

我想打印类似“Hello $gmail->firstname to the website”之类的内容, 通过从表单提供相同的用户凭据作为输入到 php 文件。

在不使用 Open ID API 的情况下有没有办法做到这一点?

我的 php 验证函数类似于:-

function validate($username,$password) {
    $username = strtolower($username);
    $server="{imap.gmail.com:993/imap/ssl}";
    $result=false;
    $result = imap_open($server,$username,$password);
    if($result) {
            return 1;
    }
    else {
            return 0;
    }
}

【问题讨论】:

    标签: php forms gmail-imap imap-open


    【解决方案1】:

    试试php的explode()函数。

    $string_array = explode("@",$string);
    echo $string_array[0];
    

    有你的答案。

    【讨论】:

    • 我认为这个功能与提取有关,我要求的代码类似于 Google Open ID 中使用的代码。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-09-20
    • 1970-01-01
    • 2014-08-30
    • 2012-11-07
    • 2017-11-28
    • 1970-01-01
    • 2012-10-09
    相关资源
    最近更新 更多