1

I am trying to make a GET request but when I try to pick up the url it cuts it in half like this:

This is the request

http://mydomain.dev/getdata?id=22232&t=1&url=http://www.example.com/Public/AView.aspx?RemoteId=3CB0CDA14-C8BC-44E3-A1B1-8E389ER3B07&PublisherG=ed4fe6d2-4543-42d4-a51c-c1cfcbcc1b3a

And here is what i get if i echo Input::get('url');

http://www.example.com/Public/AView.aspx?RemoteId=3CB0CDA14-C8BC-44E3-A1B1-8E389ER3B07

Why is this?

If it's to any help i'm using laravel 5.2

Edvard Åkerberg
  • 2,181
  • 1
  • 26
  • 47

1 Answers1

3

Input::get('url'); should be exactly what you're getting back. It's returning the value the parameter literally named url in the get request. Input::get() return get params.

If you want the actual URI for the request made, you need the request object: https://laravel.com/docs/master/requests

Also, you need to urlencode() the url you're passing as a get parameter.

$url_param = urlencode("http://www.example.com/Public/AView.aspx?RemoteId=3CB0CDA14-C8BC-44E3-A1B1-8E389ER3B07&PublisherG=ed4fe6d2-4543-42d4-a51c-c1cfcbcc1b3a");

$final_url = "http://mydomain.dev/getdata?id=22232&t=1&url=".$url_param;
Ray
  • 40,256
  • 21
  • 101
  • 138
  • Great it worked! YOu know how to do the same in Javascript? – Edvard Åkerberg Jul 06 '16 at 15:53
  • If your generating manually the full url string in javascript I think you'd want `encodeURI()` on the parameter value: http://stackoverflow.com/questions/332872/encode-url-in-javascript – Ray Jul 06 '16 at 16:01