jerryangel Posted February 22, 2013 Share Posted February 22, 2013 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 function runapp($dir,$latdeg,$latmin,$latsec,$longdeg,$longmin,$longsec) { global $_english; $query= ($_english ? 'http://esnig.org/cgi-bin/ntv2_geo2_e.cgi' : 'http://esnig.org/cgi-bin/ntv2_geo2_f.cgi'). '?' . PAR_DIR .'=' . $dir . '&' . PAR_LATDEG .'=' . $latdeg . '&' . PAR_LATMIN .'=' . $latmin . '&' . PAR_LATSEC .'=' . $latsec . '&' . PAR_LONGDEG .'=' . $longdeg . '&' . PAR_LONGMIN .'=' . $longmin . '&' . PAR_LONGSEC .'=' . $longsec; $response=file($query); foreach ($response as $value) { echo $value; } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/274812-help-me-re-write-this-function/ Share on other sites More sharing options...
jazzman1 Posted February 22, 2013 Share Posted February 22, 2013 Can you give us an example with the real data. There are too match variables on that script. Quote Link to comment https://forums.phpfreaks.com/topic/274812-help-me-re-write-this-function/#findComment-1414111 Share on other sites More sharing options...
waynew Posted February 22, 2013 Share Posted February 22, 2013 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. Quote Link to comment https://forums.phpfreaks.com/topic/274812-help-me-re-write-this-function/#findComment-1414121 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.