skeeks / yii2-google-api
Component for work with google api based on google/apiclient
Installs: 40 326
Dependents: 1
Suggesters: 0
Security: 0
Stars: 11
Watchers: 2
Forks: 1
Open Issues: 0
Type:yii2-extension
Requires
- google/apiclient: 2.1.3
- yiisoft/yii2: ^2.0.0
README
Partly wrapper over powerful official package from google — google/apiclient
Installation
The preferred way to install this extension is through composer.
Either run
php composer.phar require --prefer-dist skeeks/yii2-google-api "^2.0.1"
or add
"skeeks/yii2-google-api": "^2.0.1"
How to use
Configuration app
//App config [ 'components' => [ //.... 'googleApi' => [ 'class' => '\skeeks\yii2\googleApi\GoogleApi', 'key' => 'YOUR_GOOLE_API_KEY', ], //.... ] ]
An example of the Api transliteration
https://cloud.google.com/translate/v2/using_rest
Translate "apple"
$result = \Yii::$app->googleApi->serviceTranslate->translate('apple', 'ru'); print_r($result);
or
$result = \Yii::$app->googleApi->serviceTranslate->googleService->translations->listTranslations('apple', 'ru'); print_r($result);
or
$googleService = \Yii::$app->googleApi->serviceTranslate->googleService; $result = $googleService->translations->listTranslations('apple', 'ru'); print_r($result);
or
$googleClient = \Yii::$app->googleApi->googleClient; $googleService = new \Google_Service_Translate($googleClient); $result = $googleService->translations->listTranslations('apple', 'ru'); print_r($result);
$service = \Yii::$app->googleApi->serviceTranslate->googleService; $result = $service->languages->listLanguages([ 'target' => 'ru' ]); print_r($result);
An example other google services
$googleClient = \Yii::$app->googleApi->googleClient; $googleServiceAdsense = new \Google_Service_Adsense($googleClient); $googleServiceAdsense = new \Google_Service_Youtube($googleClient); //....
Your Google Services
//App config [ 'components' => [ //.... 'googleApi' => [ 'class' => '\skeeks\yii2\googleApi\GoogleApi', 'key' => 'YOUR_GOOLE_API_KEY', 'serviceTranslateClass' => 'skeeks\cms\googleApi\serviceTranslate\GoogleApiServiceTranslate' //or 'serviceTranslateClass' => [ 'class' => 'skeeks\cms\googleApi\serviceTranslate\GoogleApiServiceTranslate', 'option' => 'value' ], ], //.... ] ]
SkeekS CMS (Yii2) — quickly, easily and effectively!
skeeks.com | cms.skeeks.com