![](/img/trans.png)
[英]Laravel5:Redirect::to() outside link NotFoundHttpException in RouteCollection.php
[英]Laravel 5: redirect to an external link outside of localhost/server
我想使用 laravel 5 和 dropbox API 构建一个应用程序,其中我希望在您登陆主页时显示 API 允许/取消警告,而不是在您单击按钮时显示。 我尝试了不同的方法,但我无法使它起作用。
public function start(){
session(['user_id'=>1]);
$dKey = 'key';
$dSecret = 'secret';
$appName = 'app';
$appInfo = new Dropbox\AppInfo($dKey,$dSecret);
//store csrf token
$tokenStore = new Dropbox\ArrayEntryStore($_SESSION,'dropbox-auth-csrf-token');
//define auth details
$this->webAuth = new Dropbox\WebAuth($appInfo,$appName,'http://localhost:8000/dropbox/finish',$tokenStore);
$this->checkSession();
}
public function checkSession(){
$users = User::where('id','=',session('user_id'))->get();
if(isset($user[0]->dropbox_token)){
}
else{
$url = $this->webAuth->start();
//return Redirect::to($url);
//return Redirect::away($url);
//header('Location : '.$url);
}
}
$url 中的链接存在且有效。
这些(最后 3 个评论的方法)是我尝试过的方法,包括返回重定向($url),是否可以这样做,或者我是否在浪费时间?请帮助我。
这段代码对我有用:
return redirect()->away('https://www.dropbox.com');
确保您还在start()
添加了一个返回值(即return $this->checkSession();
start()
。
下面的代码将工作
return redirect()->away('http://www.paypal.com');
这也将起作用。
return redirect('http://www.paypal.com');
对于 https 等,请使用以下内容
return redirect()->to($refererUrl);
可以这样做,
use Redirect;
return Redirect::to('your url');
要不就,
return \Redirect::to('your url');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.