moux2003 / guzzle-bundle-sastoken-plugin
SAS Token 插件用于 Guzzle Bundle,Guzzle Bundle 是一个 PHP HTTP 客户端库和框架,用于构建 RESTful 服务的客户端
1.0.0
2018-02-20 13:17 UTC
Requires
- php: ^7.0
- eightpoints/guzzle-bundle: ~7.0
- guzzlehttp/guzzle: ^6.0
- symfony/config: ~2.7|~3.0|~4.0
- symfony/dependency-injection: ~2.7|~3.0|~4.0
- symfony/expression-language: ~2.7|~3.0|~4.0
- symfony/http-kernel: ~2.7|~3.0|~4.0
This package is not auto-updated.
Last update: 2024-09-29 05:41:51 UTC
README
此插件将 SAS Token(Azure)功能集成到 Guzzle Bundle 中,Guzzle Bundle 是用于构建 RESTful 服务的客户端的组件。
需求
安装
使用 composer
composer.json
{ "require": { "moux2003/guzzle-bundle-sastoken-plugin": "~1.0" } }
命令行
$ composer require moux2003/guzzle-bundle-sastoken-plugin
用法
启用组件
# app/AppKernel.php new EightPoints\Bundle\GuzzleBundle\EightPointsGuzzleBundle([ new Moux2003\GuzzleBundleSasTokenPlugin\GuzzleBundleSasTokenPlugin(), ])
基本配置
# app/config/config.yml eight_points_guzzle: clients: api_azure: base_url: "https://namespace.windows.net" # define headers, options # plugin settings plugin: sasToken: connectionString: "Endpoint=scheme://namespace.windows.net/;SharedAccessKeyName=DefaultFullSharedAccessSignature;SharedAccessKey=HaShEdKey" expires: 60 # optional
与 Guzzle 的用法
<?php $sasToken = new \Moux2003\GuzzleBundleSasTokenPlugin\Middleware\SasTokenAuthMiddleware($connectionString); $stack = \GuzzleHttp\HandlerStack::create(); // Add the sasToken middleware to the handler stack. $stack->push($sasToken->attach()); $client = new \GuzzleHttp\Client(['handler' => $stack]); $response = $client->post('https://namespace.windows.net/hubname/messages?api-version=2013-10');
许可证
此中间件采用 MIT 许可证授权 - 详细信息请参阅 LICENSE 文件