metglobal / gcp-rest-guzzle-adapter
Simple Guzzle adapter to Google Cloud Platform REST endpoints
Installs: 2 308
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Requires
- php: >=5.6
- firebase/php-jwt: 4.0
- guzzlehttp/guzzle: 5.3.*
Requires (Dev)
- phpunit/phpunit: 5.1
This package is auto-updated.
Last update: 2023-11-20 19:16:51 UTC
README
Simple Guzzle adapter to Google Cloud Platform REST APIs
Use Case
Accessing to Google Cloud Platform Rest APIs using Service Account Credentials (Google's recommended way)
For more information about authentication: https://cloud.google.com/speech/docs/common/auth
Usage
use \GcpRestGuzzleAdapter\Client\ClientFactory; // Service Account Email $email = 'pubsub@test-project123.iam.gserviceaccount.com'; // Private Key $key = '-----BEGIN PRIVATE KEY-----SDADAavaf...-----END PRIVATE KEY-----'; // Scope of Google Cloud Service $scope = 'https://www.googleapis.com/auth/pubsub'; // Full base url of project $projectBaseUrl = 'https://pubsub.googleapis.com/v1/projects/test-project123/'; $pubSubClient = ClientFactory::createClient($email, $key, $scope, $projectBaseUrl); $result = $pubSubClient->get( sprintf('topics/%s/subscriptions', 'test-topic') ); var_dump((string)$result->getBody()->getContents());
Result
string(113) "{ "subscriptions": [ "projects/test-project123/subscriptions/test_topicSubscriber" ] } "
Requirements
- php >=5.6
- guzzle 5.3
- firebase/php-jwt 4.0
- apc or apcu for token caching (custom handler also injectable)