Package Data | |
---|---|
Maintainer Username: | mingalevme |
Maintainer Contact: | mingalevme@gmail.com (Mingalev Mikhail) |
Package Create Date: | 2017-10-05 |
Package Last Update: | 2022-06-22 |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-12-15 15:10:43 |
Package Statistics | |
---|---|
Total Downloads: | 14 |
Monthly Downloads: | 1 |
Daily Downloads: | 0 |
Total Stars: | 0 |
Total Watchers: | 2 |
Total Forks: | 0 |
Total Open Issues: | 0 |
Provides Google API Library for PHP wrapper for Laravel/Lumen
composer require mingalevme/illuminate-google
.
Register the service provider Mingalevme\Illuminate\Google\GoogleServiceProvider
.
(Optionally) Add alias to your bootstrap file:
'Google' => Mingalevme\Illuminate\Google\Facades\Google::class,
php artisan vendor:publish --provider="Mingalevme\Illuminate\Google\GoogleServiceProvider" --tag="config"
to publish the config file.
(Optionally) For Lumen copy /vendor/mingalevme/illuminate-google/config/google.php
to /config/google.php
.
Instead of 4 and/or 5 if you plan to use just one Google Analytics (most common case), place JWT-file to /resources/google-service-account-key.json
, if the service is not Google Analytics, setup one in your .env:
GOOGLE_SERVICE=Google_Service_AndroidPublisher
GOOGLE_SCOPE=https://www.googleapis.com/auth/androidpublisher
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Mingalevme\Illuminate\Google\Facades\Google;
class MyController extends Controller
{
public function publisher(Request $request)
{
/* @var $publisher \Google_Service_AndroidPublisher */
$publisher = Google::service();
/* @var $purchase \Google_Service_AndroidPublisher_SubscriptionPurchase */
try {
$purchaseData = (array) $publisher->purchases_subscriptions
->get($request->input('app_id'), $request->input('product_id'), $request->input('purchase_token'))
->toSimpleObject();
} catch (\Google_Service_Exception $e) {
$purchaseData = ['errors' => $e->getErrors()];
}
return response()->json($purchaseData, isset($e) ? $e->getCode() : 200);
}
public function analytics(Request $request)
{
/* @var $analytics \Google_Service_Analytics */
$analytics = Google::service('analytics');
...
}
}