Publication time: Monday, March 28, 2016 (3 years ago)

Created by: Семенов Александр Сергеевич

Category: Other

Current version: 2.0.1
Apr 12, 2019, 11:38:51 AM (6 months ago)

Packagist: skeeks/yii2-google-api

: https://github.com/skeeks-semenov/yii2-google-api

: 10268 (Per month: 518)

Type of: Компонент

Component for work with official google api

Partly wrapper over powerful official package from google — google/apiclient

Latest Stable Version Total Downloads

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!
SkeekS CMS (Yii2) — quickly, easily and effectively!
skeeks.com | cms.skeeks.com

CHANGELOG

2.0.1

  • New version stable release

2.0.0

  • New version

1.1.0

  • Update

1.0.0

  • Stable release

All Comments (0)
No Comments

dev-master — Apr 12, 2019, 9:49:45 PM (6 months ago)

2.0.1 — Apr 12, 2019, 11:38:51 AM (6 months ago)

2.0.0 — Apr 12, 2019, 9:43:51 AM (6 months ago)

1.1.0 — Apr 11, 2019, 7:09:00 PM (6 months ago)

1.0.0 — Mar 28, 2016, 5:21:37 PM (3 years ago)

Стандартная установка:

Добавьте composer.json файл вашего проекта:

"skeeks/yii2-google-api": "*"

Запустите обновление зависимостей


Читать про обнолвение SkeekS CMS