tda/laravel-google-search-console
Composer 安装命令:
composer require tda/laravel-google-search-console
包简介
Google Analytics Admin integration with oAuh2
README 文档
README
Based on schulzefelix/laravel-search-console and modified to Laravel 8
Using this package you can easily retrieve data from Google Search Console API.
Here are a few examples of the provided methods:
Install
This package can be installed through Composer.
$ composer require tda/laravel-search-console
Usage
Here are two basic example to retrieve all sites and an export for search analytics data.
List Sites
use Tda\GoogleSearchConsole\SearchConsole; $searchConsole = new SearchConsole(); $sites = $searchConsole->setAccessToken($this->token)->listSites(); //get site details (permissionLevel) for specific site $site = $searchConsole->setAccessToken($token)->getSite('http://blog.example.com/');
Search Analytics
use Tda\GoogleSearchConsole\SearchConsole; use Tda\SearchConsole\Period; $searchConsole = new SearchConsole(); $data = $searchConsole->setAccessToken($this->token)->setQuotaUser('uniqueQuotaUserString') ->searchAnalyticsQuery( 'https://www.example.com/', Period::create(Carbon::now()->subDays(30), Carbon::now()->subDays(2)), ['query', 'page', 'country', 'device', 'date'], [['dimension' => 'query', 'operator' => 'notContains', 'expression' => 'cheesecake']], 1000, 'web', 'all', 'auto' );
Provided methos
Retrieve One Site
public function public function getSite(string $siteUrl): array
Retrieve All Sites
public function public function listSites(): Collection
Retrieve Search Analytics Data
public function searchAnalyticsQuery(string $siteUrl, Period $period, array $dimensions = [], array $filters = [], int $rows = 1000, string $searchType = 'web', string $dataState = 'final', string $aggregationType = 'auto'): Collection
Check Access Token
public function public function isAccessTokenExpired(): Bool
Provided fluent configuration
Set Quota User
To avoid to the API limits, you can provide a unique string for the authenticated account.
More information: https://developers.google.com/webmaster-tools/search-console-api-original/v3/limits
$sites = SearchConsole::setAccessToken($token)->setQuotaUser('uniqueQuotaUserString')->listSites();
Get Underlying Service
You can get access to the underlying Google_Service_Webmasters object:
SearchConsole::getWebmastersService();
Change log
Please see CHANGELOG for more information what has changed recently.
Testing
$ vendor/bin/phpunit
Contributing
Please see CONTRIBUTING and CONDUCT for details.
Credits
License
The MIT License (MIT). Please see License File for more information.
统计信息
- 总下载量: 89
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 4
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-08-14