Reading URL with cURL library. Getting error (302 Moved Temporarily)

I use cURL to get the URL content. but I get the error as “An error (302 Moved Temporarily) has occured in response to this request.”
This script works for other websites with no problems…
thanks for your help.

Here’s the script,

$URL=“http://non/working/url/page”;
$user_agent = “Mozilla/4.0”;
$curl = curl_init();
curl_setopt ($curl, CURLOPT_URL, $URL);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_VERBOSE, 1);
curl_setopt ($curl, CURLOPT_USERAGENT, $user_agent);
curl_setopt($curl, CURLOPT_COOKIEJAR, “cookie.txt”);

$String=curl_exec ($curl);
curl_close ($curl);

Try playing with curl options, ie. CURLOPT_FOLLOWLOCATION etc,

Yes. That worked for me. by setting CURLOPT_FOLLOWLOCATION to 1. thank you very much.