zend framawork中Zend_Gdata_ClientLogin实例(实现了验证码功能)

php代码

$rememberMe = $this->getRequest ()->getParam ( 'rememberMe' );
            $googleEmail = $this->getRequest ()->getParam ( 'googleEmail' );
            $googlePwd = $this->getRequest ()->getParam ( 'googlePwd' );
            $checkCode = $this->getRequest ()->getParam ( 'checkcode' );
            $service = Zend_Gdata_Calendar::AUTH_SERVICE_NAME;
            $appName = 'china-wanderer';
            $this->view->imgUrl = '';
            try {
                   $client = Zend_Gdata_ClientLogin::getHttpClient($googleEmail, $googlePwd ,$service ,null ,$appName);
            } catch (Zend_Gdata_App_CaptchaRequiredException $cre) {
                if($checkCode) {
                    $client = Zend_Gdata_ClientLogin::getHttpClient($googleEmail, $googlePwd ,$service ,null ,$appName ,
                    $cre->getCaptchaToken() ,$checkCode);
                } else {
                    $this->getSession()->addError($this->__('Please checke your username and passwork,enter the checkcode,then try again'));
                    $this->view->imgUrl = $cre->getCaptchaUrl();
                }
            } catch (Zend_Gdata_App_AuthException $ae) {
                   $this->getSession()->addError($this->__('Login fail,please check your username and password,then try again'));
            } catch (Zend_Gdata_App_Exception $ze) {
                $this->getSession()->addError($this->__('There is something wrong with the network,unable to Connect to ssl://www.google.com:443'));
            } catch (Zend_Gdata_App_HttpException $he) {
                $this->getSession()->addError($this->__('Login fail,please check your username and password,then try again'));
            }

 

 

 

html页面代码

<form id="gooleLogin" action="<?php echo $this->url(array(), 'backend_login')?>" method="post">
            <input type="hidden" name="gg" value="login" />
            <p class="main">
                <label><?php echo $this->__('Username: ') ?></label>
                <input name="googleEmail" value="<?php if(isset($googleEmail)):?><?php echo $googleEmail;?><?php endif;?>" />
                <label><?php echo $this->__('Password: ') ?></label>
                <input type="password" name="googlePwd" value="<?php if(isset($googlePwd)):?><?php echo $googlePwd;?><?php endif;?>">
            </p>
            <?php if($this->imgUrl) {?>
                <p class="main" style="padding-top:10px;">
                <label><?php echo $this->__('Checkcode: ') ?></label>
                <input name="checkcode" value="" type="text" />
                <img src="<?php echo $this->imgUrl?>"></img>
                </p>
            <?php }?>
            <p class="space">
                <span><input name="rememberMe"  <?php if(isset($googleEmail)):?>checked="checked"<?php endif;?> type="checkbox" />Remember me
                </span>
                <input type="submit" value="Login" class="login" /><span style="color:red">(please login with you gmail)</span>
            </p>
            </form>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值