PHP临时移动错误?我在Android中使用c2dm

PHP临时移动错误?我在Android中使用c2dm,php,android,Php,Android,你能帮我解决以下问题吗 我正在运行一个脚本来验证来自google的客户端,然后我得到了以下错误 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

你能帮我解决以下问题吗

我正在运行一个脚本来验证来自google的客户端,然后我得到了以下错误

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] => [error] => No Error )
你可以在这里看到这个错误

实际上,我正在尝试在我的android应用程序上使用c2dm-云到设备的消息传递

这是剧本

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

// open socket to filehandle(epdq encryption cgi)
$fp = fsockopen( $host, 80, &$errno, &$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&Email=myemail&Passwd=mypassword&service=c2dm&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);
    }
echo$fp.“
”; echo$输出。“
”; $returnArr=array()


HTTP 302不正确,错误为

上面说你要去的页面已经被移动了

实际上,它只是用来重定向网站中的浏览器。 在您的情况下,您必须遵循
位置:
给出的重定向


我打赌您必须存储第一个请求中的Cookie,以便重定向到的页面可以根据您的登录为您提供内容。

HTTP 302不正确,错误为

上面说你要去的页面已经被移动了

实际上,它只是用来重定向网站中的浏览器。 在您的情况下,您必须遵循
位置:
给出的重定向

我打赌您必须存储第一次请求的cookies,以便重定向到的页面可以根据您的登录为您提供内容

    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;