能否请您帮我解决以下问题。
我正在运行一个脚本来验证来自 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 )
你可以在这里查看这个错误 http://iphoneappcompany.com/fan_connect/test-c2dm.php
实际上我正在尝试在我的 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();
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;
最佳答案
HTTP 302 不是错误。
它表示您尝试访问的页面已被移动。
实际上,它只是用于网站中的浏览器重定向。
在您的情况下,您必须遵循 Location: <a href="https://www.google.com/accounts/ClientLogin" rel="noreferrer noopener nofollow">https://www.google.com/accounts/ClientLogin</a>
给出的重定向.
我敢打赌,您必须存储来自您的第一个请求的 cookie,以便您被重定向到的页面可以根据您的登录信息为您提供内容。
关于PHP Moved Temporarily 错误?我在 Android 中使用 c2dm,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4141874/