doumaqing6652 2016-08-26 03:18
浏览 72
已采纳

Laravel在不使用表单的情况下将数据从视图POST到ROUTE

I'm not sure what's the best way to implement this but here is what I have going

On my register.blade.php view I have a button that links to an external api link,once clicked the api will redirect the response back to register.blade.php or [localhost:8000/register] as a GET request (I have no control over that matter, only the redirect link)

how would I pass the GET data to my custom authentication controller.

Or is there a better way to implement this?

The API returns the following data and will be used to store the data in a db and authenticate the user

  • Account ID
  • Nickname
  • Access_Token (will be used to make more api calls)
  • 写回答

1条回答 默认 最新

  • doupang4126 2016-08-26 03:26
    关注

    IF the API is redirecting back as get, but has post data for example: http://localhost:8000/register?someval=something -- you'd simply use request('someval') to get that data, or you could in your control add Request $request in the attribute of the function i.e.

        public function myfunc(Request $request){
          dd($request->somevar) // will die and dump: showing "something" as a string.    
        }
    

    Whether you're sending data via get, post, patch, and use normal static post, or ajax -it'll still work. You can even pass ajax to the call. I recommend using Postman to test out get/posts it's a Chrome plugin.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 求差集那个函数有问题,有无佬可以解决
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题