This is a discussion on fopen question. within the PHP Language forums, part of the PHP Programming Forums category; Is there a limit to how long a URL can be with fopen? I have a very long URL as ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Is there a limit to how long a URL can be with fopen? I have a very
long URL as there are lots of things to be passed some variables and some XML. It seems to get to a certain point and then produce an error with no details and just cuts it off. <?php $url = 'http://test.com/Test.dll?API=test&XML='. '<FromLastName>FromLast</FromLastName>'. '<FromFirm>FromFirm</FromFirm>'. '<FromAddress1>FromAddress1</FromAddress1>'. '<FromAddress2>6406IvyLane</FromAddress2>'. '<FromCity>Greenbelt</FromCity>'. '<FromState>MD</FromState>'. '<FromZip5>20770</FromZip5>'. '<FromZip4>1234</FromZip4>'. '<FromPhone>3019187658</FromPhone>'. '<ToAddress1>ToAddress1</ToAddress1>'. '<ToAddress2>ToAddress2</ToAddress2>'. '<ToAddress3>ToAddress3</ToAddress3>'. '<ToAddress4>ToAddress4</ToAddress4>'. '<ToAddress5>ToAddress5</ToAddress5>'. '<ToAddress6>ToAddress6</ToAddress6>'. '<ToCountry>France</ToCountry>'. '<ToAPOFPOZip5></ToAPOFPOZip5>'. '<ToPhone></ToPhone>'. '<ToFax></ToFax>'. '<ToEmail></ToEmail>'. '<ShippingContents><ItemDetail>'. '<Description>Description1</Description>'. '<Quantity>1</Quantity>'. '<Value>1</Value>'. '<NetPounds>5</NetPounds>'. '<NetOunces>0</NetOunces>'. '</ItemDetail><ItemDetail>'. '<Description>Descripton2</Description>'. '<Quantity>5</Quantity>'. '<Value>17</Value>'. '<NetPounds>2</NetPounds>'. '<NetOunces>2</NetOunces>'. '</ItemDetail></ShippingContents>'. '<GrossPounds>7</GrossPounds>'. '<GrossOunces>2</GrossOunces>'. '<ImageType>GIF</ImageType>'. '<ContentType>Gift</ContentType>'. '<HSTariffNumber></HSTariffNumber>'. '<CountryOfOrigin></CountryOfOrigin>'. '<CustomerRefNo></CustomerRefNo>'. '</CustomsCN22CertifyRequest>'; $aurl=fopen($xml,"r"); while (!feof ($aurl, 4096)) $xml .= fgets($aurl); fclose ($aurl); ?> |
|
|||
|
"theouimets" wrote:
> Is there a limit to how long a URL can be with fopen? I have a very > long URL as there are lots of things to be passed some variables and > some XML. It seems to get to a certain point and then produce an error > with no details and just cuts it off. > > snip... > ?> http://ca3.php.net/manual/en/functio...et-timeout.php -- http://www.dbForumz.com/ This article was posted by author's request Articles individually checked for conformance to usenet standards Topic URL: http://www.dbForumz.com/PHP-fopen-ftopict142029.html Visit Topic URL to contact author (reg. req'd). Report abuse: http://www.dbForumz.com/eform.php?p=474952 |
|
|||
|
theouimets@hotmail.com wrote:
> Is there a limit to how long a URL can be with fopen? I have a very > long URL as there are lots of things to be passed some variables and > some XML. It seems to get to a certain point and then produce an error > with no details and just cuts it off. > With long requests it's almost always better to use the POST method instead of GET. Consider the following snippet or use one of the many classes available on the net: // Construct the request string $request = "API=test&XML=" . urlencode("<FormLastName..."); // Open connection $fp = fsockopen("test.com", 80); // Send the request fputs($fp, "POST /Test.dll HTTP/1.0\r\n"); fputs($fp, "Host: test.com\r\n"); fputs($fp, "Content-Length: " . strlen($request) . "\r\n"); fputs($fp, "Content-Type: application/x-www-form-urlencoded\r\n\r\n"); fputs($fp, "$request\r\n"); fputs($fp, "\r\n"); // Print the response fpassthru($fp); // Close the connection fclose($fp); JW |
|
|||
|
Janwillem Borleffs wrote:
> With long requests it's almost always better to use the POST method > instead of GET. > Be also aware that '&' and '=' are reserved characters in request strings and are used as parameter and parameter/value separators respectively. When you send: $url = 'http://test.com/Test.dll?API=test&XML='. '<FromLastName>FromLast</FromLastName>'. you should urlencode the ampersands in the value of the XML parameter. See the example I posted before. JW |