Giter Site home page Giter Site logo

skeeks-semenov / yii2-google-api Goto Github PK

View Code? Open in Web Editor NEW
11.0 2.0 1.0 29 KB

Component for work with official google api

Home Page: https://skeeks.com

License: BSD 3-Clause "New" or "Revised" License

PHP 100.00%
apiclient skeeks yii yii2 yii2-extension skeeks-cms google api api-client googleapi

yii2-google-api's Introduction

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.