Jump to content

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.