rewrite php code to avoid failed to open stream: HTTP request failed
<p>I have been searching for the correct answers on how to to fix this common error on php code: <code>failed to open stream: HTTP request failed!</code> I really think that the solution lies in rewriting the code to bypass the the <code>User-Agent</code> http header in the code. The file I need to access is on the same server as this code. I need help on how I can rewrite the function part of this script:</p>

<pre><code>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 .
        '&amp;' . PAR_LATDEG  .'=' . $latdeg .
        '&amp;' . PAR_LATMIN  .'=' . $latmin .
        '&amp;' . PAR_LATSEC  .'=' . $latsec .
        '&amp;' . PAR_LONGDEG .'=' . $longdeg .
        '&amp;' . PAR_LONGMIN .'=' . $longmin .
        '&amp;' . PAR_LONGSEC .'=' . $longsec;


    $response=file($query); 

    foreach ($response as $value)
    {
        echo $value;
    }
}
?&gt;
</code></pre>
