PHP Webpage Request returns 400 Bad Request
<p>I have tried using fopen, file-get-contents and a curl request but I always get 400 Bad Request returned. This is a simple webpage request with GET params. Here is my code, can anyone see why this would be causing problems? phpinfo(); shows the config allows these sorts of requests.</p>

<pre><code>function get_web_page( $url )
{
    $options = array(
        CURLOPT_RETURNTRANSFER =&gt; true,     // return web page
        CURLOPT_HEADER         =&gt; false,    // don't return headers
        CURLOPT_FOLLOWLOCATION =&gt; true,     // follow redirects
        CURLOPT_ENCODING       =&gt; "",       // handle all encodings
        CURLOPT_USERAGENT      =&gt; "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.8.1) Gecko/20061010 Firefox/2.0", // who am i
        CURLOPT_AUTOREFERER    =&gt; true,     // set referer on redirect
        CURLOPT_CONNECTTIMEOUT =&gt; 120,      // timeout on connect
        CURLOPT_TIMEOUT        =&gt; 120,      // timeout on response
        CURLOPT_MAXREDIRS      =&gt; 10,       // stop after 10 redirects
    );

    $ch      = curl_init( $url );
    curl_setopt_array( $ch, $options );
$this-&gt;headers = array(
    'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8, image/gif, image/x-bitmap, image/jpeg, image/pjpeg',
    'Connection: Keep-Alive',
    'Content-type: application/x-www-form-urlencoded;charset=UTF-8'
);
    curl_setopt($ch, CURLOPT_HTTPHEADER, $this-&gt;headers);
    $content = curl_exec( $ch );
    $err     = curl_errno( $ch );
    $errmsg  = curl_error( $ch );
    $header  = curl_getinfo( $ch );
    curl_close( $ch );

    $header['errno']   = $err;
    $header['errmsg']  = $errmsg;
    $header['content'] = $content;
    return $header;
}
</code></pre>

<p>....</p>

<pre><code>        $forwardURL = '*****/receive?from='.$_GET["from"].'&amp;msg='.$_GET['msg'].'&amp;username='.$_GET['username'].'&amp;ac_password='.$_GET['ac_password'].'&amp;to='.$_GET['to'].'&amp;do='.$_GET['do'];
print_r($this-&gt;get_web_page($forwardURL));
</code></pre>

<p>If I paste $forwardURL into my browser it works fine.</p>

<p>output:</p>

<pre><code>Array ( [url] =&gt; http://************/receive?from=*****&amp;msg=*********&amp;username=*******&amp;ac_password=*****&amp;to=********&amp;do=send [content_type] =&gt; text/html; charset=us-ascii [http_code] =&gt; 400 [header_size] =&gt; 179 [request_size] =&gt; 594 [filetime] =&gt; -1 [ssl_verify_result] =&gt; 0 [redirect_count] =&gt; 0 [total_time] =&gt; 0.053303 [namelookup_time] =&gt; 0.000996 [connect_time] =&gt; 0.025709 [pretransfer_time] =&gt; 0.025711 [size_upload] =&gt; 0 [size_download] =&gt; 311 [speed_download] =&gt; 5834 [speed_upload] =&gt; 0 [download_content_length] =&gt; 311 [upload_content_length] =&gt; 0 [starttransfer_time] =&gt; 0.053264 [redirect_time] =&gt; 0 [errno] =&gt; 0 [errmsg] =&gt; [content] =&gt;
Bad Request

HTTP Error 400. The request is badly formed.

)
</code></pre>
