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>