php - Google Search Console API - SearchAnalytics 500 错误

标签 php api google-search-console

我正在尝试使用 SearchAnalyticsQuery 从 Search Console Api 中获取一些数据。

首先我用 PHP 尝试过:

     $this->client->setAccessToken( \Session::get('access_token') );

        $webmaster =  new \Google_Service_Webmasters( $this->client );

        $q = new \Google_Service_Webmasters_SearchAnalyticsQueryRequest();

        $q->setStartDate('2015-01-01');

        try {

            $webmaster->searchanalytics->query('http://example.com', $q);

        } catch(\Exception $e )
        {
            dd($e);
        }

我有一个有效的 token ,它执行请求,但始终返回以下内容:

Error calling POST https://www.googleapis.com/webmasters/v3/sites/example.com/searchAnalytics/query: (500) Backend Error

为了确保它不是由 PHP 代码引起的,我还使用 Google Api Explorer 进行了尝试。

这里的结果相同:/image/hWECi.png

我目前使用的是 https://github.com/google/google-api-php-client 的 dev-master 版本

一定是我做错了什么,我只是无法弄清楚。

最佳答案

您没有设置endDate(必需参数) - 请参阅 official documentation .

关于php - Google Search Console API - SearchAnalytics 500 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32653675/

相关文章:

iphone - 当我删除我的 iOS 应用程序时,推送通知状态仍然存在

seo - 使用 Google Search Console 测试站点,不允许其公开列出

php - Laravel 5.4 子查询在什么条件下?

php - 原则对产品有问题,但对开发没有问题

node.js - 指定永远不应在 Swagger 或 OpenAPI 中发送的属性

api - Telegram 机器人可以搜索用户联系人吗?

php - 如何在 Magento 页脚中编写 php 循环?

php - mysql select 总计不存在

seo - 谷歌站点链接问题

google-analytics - 网站管理员工具不工作 - 总点击次数为 0