Amanda1990 Amanda1990 -4 years ago 149
PHP Question

Laravel POST data from view to ROUTE without using a form

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

On my

view I have a button that links to an external api link,once clicked the api will redirect the response back to
or [
] as a
request (I have no control over that matter, only the redirect link)

how would I pass the
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)

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download