Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/292.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 重定向到Zend Framework中不工作的路由_Php_Zend Framework2_Google Oauth - Fatal编程技术网

Php 重定向到Zend Framework中不工作的路由

Php 重定向到Zend Framework中不工作的路由,php,zend-framework2,google-oauth,Php,Zend Framework2,Google Oauth,我的应用程序使用Zend Framework 2.2.4,我在登录页面添加了“使用谷歌登录”选项。但它并没有在确切的页面上重定向,而是返回到登录页面并放置一个# 例如。 myapp.dev/login# 这是“使用谷歌登录”的方法,它位于我的LoggingController.php 公共函数loginsocialAction() { $googleClient=$this->getGoogleClient(); $code=$this->params()->fromQuery('code','

我的应用程序使用Zend Framework 2.2.4,我在登录页面添加了“使用谷歌登录”选项。但它并没有在确切的页面上重定向,而是返回到登录页面并放置一个#

例如。 myapp.dev/login#

这是“使用谷歌登录”的方法,它位于我的
LoggingController.php

公共函数loginsocialAction()
{
$googleClient=$this->getGoogleClient();
$code=$this->params()->fromQuery('code','');
$googleOauthV2=new\Google_OAuth2服务($googleClient);
#如果谷歌验证成功
if(isset($代码)){
$googleClient->authenticate($code);
$gdata=$googleOauthV2->userinfo->get();
$user=$this->getUsersTable()->getByEmail($gdata['email']);
}
if($googleClient->getAccessToken()&&isset($gdata['email'])){
如果(!empty($user)){
$user->role=$this->getRoleTable()->get($user->roleId);
$session=newsession\Container('currentuser');
$session->user=$user;
$this->initializeSession($session);
//如果成功,请转到记录页面
返回$this->redirect()->toRoute('records');
}否则{
$message='用户不在系统中';
$this->flashMessenger()->setNamespace('error')->addErrorMessage($message);
返回$this->redirect()->toRoute('login');
}
}否则{
$message='Google auth失败';
$this->flashMessenger()->setNamespace('error')->addErrorMessage($message);
返回$this->redirect()->toRoute('login');
}
}

请说出我错过的或你想知道的事情。任何想法都会很有帮助

您可以尝试此方法进行重定向

用于控制器重定向

return$this->redirect()->toUrl($this->getRequest()->getBaseUrl()。/any/path/here/);
用于视图重定向

在这种情况下,单击按钮取消时会重定向,重置值

<button type="reset"   
   <a  href="<?php echo $this->basePath('your/path/here/'. <<ID HERE IF ANY>> ) ?>">Cancel
         </a>
</button>
请提供您的路线(
登录
记录
),错误可能在那里。
<button type="reset"   
   <a  href="<?php echo $this->basePath('your/path/here/'. <<ID HERE IF ANY>> ) ?>">Cancel
         </a>
</button>