Laravel 5:重定向到localhost/server外部的外部链接 [英] Laravel 5: redirect to an external link outside of localhost/server

查看:948
本文介绍了Laravel 5:重定向到localhost/server外部的外部链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用laravel 5&我希望Dropbox API能够在您登陆首页时(而不是在您单击按钮时)显示API允许/取消警告. 我尝试了不同的方法,但无法使其正常工作.

I want to build an app with laravel 5 & dropbox API in which I want the API allow/cancel-warning to be displayed when you land on the homepage, not when you click a button. I tried different methods but I couldn`t make it work.

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中的链接存在并且有效.

The link in $url exists and its valid.

这些(最近3条评论的方法)是我尝试过的方法,包括return redirect($ url),有可能这样做还是我在浪费时间?请帮帮我.

These(last 3 commented methods) are the methods i tried , including return redirect($url),is it possible to do this or am i wasting my time with this ?please help me out.

推荐答案

此代码对我有用:

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

确保您还在start()中添加了退货单(即return $this->checkSession();).

Make sure you also add a return (i.e. return $this->checkSession();) in start().

这篇关于Laravel 5:重定向到localhost/server外部的外部链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆