Long urls with over 4095 characters in php

$url = "http://example.com/............." 

$ url has over 4095 characters. I need to access this url in php, but if I use file or file_get_contents it returns an error

How can I open or access this url in php?

+4
source share
5 answers

Your problem is not PHP, this is the insanity of your requirement. :) Also;

What is the maximum URL length in different browsers?

Of course you want a POST instead of a crazy GET. This is more like a fundamental system design problem.

+4
source

It depends on the type of server you are trying to access.

For instance:

Apache: limits the length of the URL to LimitRequest *, the default URL is 8 Kbytes.

Microsoft Internet Information Server: By default, it has 16 KB. But it can be changed.

Perl HTTP :: Daemon: 8,000 characters for the URL length and 16 KB for the HTTP header. Values ​​are subject to change in Daemon.pm.

+1
source

The error you received was generated by the remote server ... this service cannot process URLs longer than the specified number of characters.

if this API relies on GET requests and should be used the way you use it, your problem is a design error in the API used and has nothing to do with PHP. if you cannot change the API or the service that provides access to the API, you cannot solve this problem.

+1
source

As Raymond Chen wrote, if you need to ask, you probably did something wrong . In your case, you should explicitly use POST instead of GET.

0
source

All Articles