PHP Moved Temporarily error? i am using c2dm in Android 
<p>Can you please help me to solve the following problem.</p>

<p>I am running  a script to authenticate client from google and then i got the following error</p>

<pre><code>Resource id #4
HTTP/1.0 302 Moved Temporarily Content-Type: text/html; charset=UTF-8 Location: https://www.google.com/accounts/ClientLogin Content-Length: 225 Date: Wed, 10 Nov 2010 06:33:40 GMT Expires: Wed, 10 Nov 2010 06:33:40 GMT Cache-Control: private, max-age=0 X-Content-Type-Options: nosniff X-XSS-Protection: 1; mode=block Server: GSE
Moved Temporarily

The document has moved here. 
0Array ( [authToken] =&gt; [error] =&gt; No Error )
</code></pre>

<p>u can have a look of this error here
<a href="http://iphoneappcompany.com/fan_connect/test-c2dm.php" rel="nofollow">http://iphoneappcompany.com/fan_connect/test-c2dm.php</a></p>

<p>Actually i am trying to use c2dm- cloud to device messaging on my android application</p>

<p>here is the script</p>

<p>$host = 'www.google.com';
    $usepath = '/accounts/ClientLogin';</p>

<pre><code>// open socket to filehandle(epdq encryption cgi)
$fp = fsockopen( $host, 80, &amp;$errno, &amp;$errstr, 60 );

//check that the socket has been opened successfully
if( !$fp ) {
    $returnArr = array();
    $returnArr['authToken']=0;
    $returnArr['error'] = "$errstr ($errno)";
} else {

    $params = "accountType=HOSTED_OR_GOOGLE&amp;Email=myemail&amp;Passwd=mypassword&amp;service=c2dm&amp;source=appsource";

    //write the data to the request
    fputs( $fp, "POST $usepath HTTP/1.0\n");
    $strlength = strlen( $params );
    fputs( $fp, "Content-type: application/x-www-form-urlencoded\n" );
    fputs( $fp, "Content-length: ".$strlength."\n\n" );
    fputs( $fp, $params."\n\n" );

    //clear the response data
    $output = "";

    //read the response from the remote cgi
    //while content exists, keep retrieving document in 1K chunks
    while( !feof( $fp ) ) {
        $output .= fgets( $fp, 1024);
    }
</code></pre>

<p>echo $fp."<br/>";
echo $output."<br/>";
        $returnArr = array();</p>

<pre><code>    if(contains("Error=", $output)){

        $error = strstr($str, 'Error=');
        $final_error = "";

        if(contains("BadAuthentication", $output)){
            $final_error = "BadAuthentication - The login request used a username or password that is not recognized.";
        }else if(contains("NotVerified", $output)){
            $final_error = "NotVerified - The account email address has not been verified. The user will need to access their Google account directly to resolve the issue before logging in using a non-Google application. ";
        }else if(contains("TermsNotAgreed", $output)){
            $final_error = "TermsNotAgreed - The user has not agreed to terms. The user will need to access their Google account directly to resolve the issue before logging in using a non-Google application. ";
        }else if(contains("CaptchaRequired", $output)){
            $final_error = "CaptchaRequired - A CAPTCHA is required. (A response with this error code will also contain an image URL and a CAPTCHA token.)";
        }else if(contains("Unknown", $output)){
            $final_error = "Unknown - The error is unknown or unspecified; the request contained invalid input or was malformed.";
        }else if(contains("AccountDeleted", $output)){
            $final_error = "AccountDeleted - The user account has been deleted.";
        }else if(contains("AccountDisabled", $output)){
            $final_error = "AccountDisabled - The user account has been disabled.";
        }else if(contains("ServiceDisabled", $output)){
            $final_error = "ServiceDisabled - The user's access to the specified service has been disabled. (The user account may still be valid.)";
        }else if(contains("ServiceUnavailable", $output)){
            $final_error = "ServiceUnavailable - The service is not available; try again later.";
        }

        $returnArr['authToken']=0;
        $returnArr['error'] = $final_error;
    }else{
        // we have an authToken
        $toeknString = strstr($str, 'Auth=');
        $token = substr($toeknString, 5);
        setAuthToken($token);
        $returnArr['authToken']= $token;
        $returnArr['error'] = "No Error";
    }
}
print_r($returnArr);
return $returnArr;
</code></pre>
