PHP code example of skeeks / yii2-google-api
1. Go to this page and download the library: Download skeeks/yii2-google-api library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
skeeks / yii2-google-api example snippets
//App config
[
'components' =>
[
//....
'googleApi' =>
[
'class' => '\skeeks\yii2\googleApi\GoogleApi',
'key' => 'YOUR_GOOLE_API_KEY',
],
//....
]
]
$result = \Yii::$app->googleApi->serviceTranslate->translate('apple', 'ru');
print_r($result);
$result = \Yii::$app->googleApi->serviceTranslate->googleService->translations->listTranslations('apple', 'ru');
print_r($result);
$googleService = \Yii::$app->googleApi->serviceTranslate->googleService;
$result = $googleService->translations->listTranslations('apple', 'ru');
print_r($result);
$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);
$googleClient = \Yii::$app->googleApi->googleClient;
$googleServiceAdsense = new \Google_Service_Adsense($googleClient);
$googleServiceAdsense = new \Google_Service_Youtube($googleClient);
//....
//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'
],
],
//....
]
]
php composer.phar