hametuha/gapiwp
最新稳定版本:1.0.3
Composer 安装命令:
composer require hametuha/gapiwp
包简介
Google API Library wrapper for WordPress.
README 文档
README
Google API Library wrapper for WordPress.
How to use
Install
Install this libary in your theme or plugin via Composer.
To do so, you need write commposer.json like below.
{
"name": "your-name/your-theme",
"description": "WordPress theme",
"require": {
"hametuha/gapiwp": "1.0.x"
}
}
Now you can execute composer install. Google API Client is a bit bigger library, --no-dev option is recommended.
composer install --no-dev
Load library
In your entry point( theme's functions.php or plugin's base file), initialize library.
// Load auto loader. include __DIR__.'/vendor/autoload.php'; // Initialize library \Hametuha\GapiWP\Loader::load();
Googla Analytics
Currently, only Google Analytics API is supported. You can now easily contact with Google Analytics data.
After initliazing the library, you can see setting screen on admin panel. Go to Setting > Analytics Setting.
What you should enter is...
- Client ID
- Client secret
You can get them on Google Developers console. Besides that, you have to save your admin screen URL(e.g. http://local.sample.in/wp-admin//options-general.php?page=gapiwp-analytics) as redirect URI. It will be treated as white-listed.
// Get Google Analytics client. $ga = \Hametuha\GapiWP\Loader::analytics(); // Get top 100 pave views of this year. $result = $ga->fetch('2015-01-01', date_i18n('Y-m-d'), 'ga:pageviews', array( 'max-results' => 100, 'dimensions' => 'ga:pagePath', 'sort' => '-ga:pageviews' )); // See what is retrieved. var_dump($result); exit;
Lisence
Released under MIT lisence. See LISENCE.md.
统计信息
- 总下载量: 1.8k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 5
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-04-20