Google Analytics API请求返回验证码?

问题描述 投票:1回答:2

[从昨天开始,我们与Google Analytics(分析)API的连接返回了一个带有...验证码的HTML页面。有人遇到这样的事情吗?

我们将API与PHP库一起使用。我们用于获取报告的代码(报告包装在我们自己的类中,但是使用google / apiclient包):

// Create analytics
$this->analytics = new \Google_Service_AnalyticsReporting($this->client);

// Create the ReportRequest object.
$request = new \Google_Service_AnalyticsReporting_ReportRequest();
$request->setViewId($view_id);
$request->setDateRanges($this->dateRanges);
$request->setMetrics( array_values( $this->metrics ) );
$request->setDimensions( array_values( $this->dimensions ) );
$request->setSegments($this->segments);

$body = new \Google_Service_AnalyticsReporting_GetReportsRequest();
$body->setReportRequests( array( $request) );

try {
    $reports = $this->analytics->reports->batchGet( $body );
}
catch(\Google_Service_Exception $e)
{
    echo"Error (1)...\n";
    echo $e->getMessage() . "\n";

    $this->lastError = json_decode($e->getMessage());
    return false;
}

我们捕获到Google Service异常,并且错误消息如下:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head><meta http-equiv="content-type" content="text/html; charset=utf-8"><meta name="viewport" content="initial-scale=1"><title>https://analyticsreporting.googleapis.com/v4/reports:batchGet</title></head>
<body style="font-family: arial, sans-serif; background-color: #fff; color: #000; padding:20px; font-size:18px;" onload="e=document.getElementById('captcha');if(e){e.focus();}">
<div style="max-width:400px;">
<hr noshade size="1" style="color:#ccc; background-color:#ccc;"><br>
<form id="captcha-form" action="index" method="post">
To continue, please type the characters below:<br><br>
<img src="/sorry/image?id=14645528721876966739&amp;q=EgSIkL9bGIjOzu4FIhkA8aeDSycUmKeaKy3bPExiN-Ol2PpxQzOfMgFj&amp;hl=en&amp;continue=https://analyticsreporting.googleapis.com/v4/reports:batchGet" border="1" alt="Please enable images"><br><br>
<input type="text" name="captcha" value="" id="captcha" size="12" style="font-size:16px; padding:3px 0 3px 5px; margin-left:0px;"><br><br><br>
<input type="submit" name="btn-submit" value="Submit" style="font-size:18px; padding:4px 0;">
<input type='hidden' name='q' value='EgSIkL9bGIjOzu4FIhkA8aeDSycUmKeaKy3bPExiN-Ol2PpxQzOfMgFj'><input type="hidden" name="continue" value="https://analyticsreporting.googleapis.com/v4/reports:batchGet">
</form>
<hr noshade size="1" style="color:#ccc; background-color:#ccc;">

<div style="font-size:13px;">
<b>About this page</b><br><br>

Our systems have detected unusual traffic from your computer network.  This page checks to see if it&#39;s really you sending the requests, and not a robot.  <a href="#" onclick="document.getElementById('infoDiv').style.display='block';">Why did this happen?</a><br><br>

<div id="infoDiv" style="display:none; background-color:#eee; padding:10px; margin:0 0 15px 0; line-height:1.4em;">
This page appears when Google automatically detects requests coming from your computer network which appear to be in violation of the <a href="//www.google.com/policies/terms/">Terms of Service</a>. The block will expire shortly after those requests stop.  In the meantime, solving the above CAPTCHA will let you continue to use our services.<br><br>This traffic may have been sent by malicious software, a browser plug-in, or a script that sends automated requests.  If you share your network connection, ask your administrator for help &mdash; a different computer using the same IP address may be responsible.  <a href="//support.google.com/websearch/answer/86640">Learn more</a><br><br>Sometimes you may be asked to solve the CAPTCHA if you are using advanced terms that robots are known to use, or sending requests very quickly.
</div>

IP address: xxx.xxx.xxx.xxx<br>Time: 2019-11-19T08:25:44Z<br>URL: https://analyticsreporting.googleapis.com/v4/reports:batchGet<br>
</div>
</div>
</body>
</html>

如果有人也遇到这种情况或有解决方案,请告诉我。

提前感谢。

google-api google-analytics-api google-api-php-client
2个回答
0
投票

我们也在经历这种情况,有人知道我们应该在Google找谁咨询这个问题吗?enter image description here


0
投票

[这可能是Google采取了一些安全措施来处理大量流量。我也知道他们从2019年11月4日开始更新了API的错误消息,这可能就是为什么我们现在收到此错误而不是之前的其他错误的原因。

我遇到了与上面突出显示的相同的问题,验证码图像未显示。我发现该服务可以小剂量重新运行,而无需更改任何代码。

我建议重试并限制请求数,直到服务恢复100%。

© www.soinside.com 2019 - 2024. All rights reserved.