Jump to content

help me re-write this function


jerryangel

Recommended Posts

Please can you helpme rewrite this code to bypass the the User-Agent http header in this code. I have been getting the error "failed to open stream: HTTP request failed" I need to stop the error when I run the code. Please find part of the script below: If you nee more information please let me know

  1. function runapp($dir,$latdeg,$latmin,$latsec,$longdeg,$longmin,$longsec)
  2. {
  3. global $_english;
  4. $query= ($_english ? 'http://esnig.org/cgi-bin/ntv2_geo2_e.cgi' : 'http://esnig.org/cgi-bin/ntv2_geo2_f.cgi').
  5. '?' . PAR_DIR .'=' . $dir .
  6. '&' . PAR_LATDEG .'=' . $latdeg .
  7. '&' . PAR_LATMIN .'=' . $latmin .
  8. '&' . PAR_LATSEC .'=' . $latsec .
  9. '&' . PAR_LONGDEG .'=' . $longdeg .
  10. '&' . PAR_LONGMIN .'=' . $longmin .
  11. '&' . PAR_LONGSEC .'=' . $longsec;
  12. $response=file($query);
  13. foreach ($response as $value)
  14. {
  15. echo $value;
  16. }
  17. }
  18. ?>

Link to comment
https://forums.phpfreaks.com/topic/274812-help-me-re-write-this-function/
Share on other sites

You should look into using the function http_build_query:

 

<?php
$query = array(
   'my' => 'milkshake',
   'brings' => 'all',
   'the' => 'boys',
   'to' => 'the',
   'yard' => 'and',
   'they\'re' => 'like',
   'it\'s' => 'better than yours!'
);

echo http_build_query($query);
?>

 

It'll spit out a URL-encoded query string.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.