gpt4 book ai didi

php - 拉维尔 5 : redirect to an external link outside of localhost/server

转载 作者:IT王子 更新时间:2023-10-29 00:01:02 24 4
gpt4 key购买 nike

我想使用 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 个评论的方法)是我尝试过的方法,包括 return redirect($url),是否可以这样做,或者我是否在浪费时间?请帮助我。

最佳答案

这段代码对我有用:

return redirect()->away('https://www.dropbox.com');

确保您还在 start() 中添加了一个返回(即 return $this->checkSession();)。

关于php - 拉维尔 5 : redirect to an external link outside of localhost/server,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29158074/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com