我想使用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');