wyveo/craft-guzzle
Composer 安装命令:
composer require wyveo/craft-guzzle
包简介
Utilise the Guzzle HTTP client from within your Craft templates.
README 文档
README
Guzzle plugin for Craft CMS 3.x
Utilise the Guzzle HTTP client from within your Craft templates. (Forked from Luke Youell)
Requirements
This plugin requires Craft CMS 3.0.0 or later.
Installation
To install the plugin, follow these instructions.
-
Open your terminal and go to your Craft project:
cd /path/to/project -
Then tell Composer to load the plugin:
composer require wyveo/craft-guzzle -
In the Control Panel, go to Settings → Plugins and click the "Install" button for Guzzle.
Using Guzzle
This plugin is built to work with the standard Guzzle request options
Parameters
| Parameter | Example value |
|---|---|
client |
{ base_uri : 'https://gtmetrix.com', timeout : 10 } |
method |
'POST' |
destination |
'api/0.1/test' |
options |
{ auth : ['username', 'password'] } |
format |
'raw' |
Example Usage
Request
{% set client = {
base_uri : 'https://gtmetrix.com',
timeout : 10
} %}
{% set options = {
auth : ['username', 'password'],
form_params : {
url : 'https://www.google.co.uk'
}
} %}
{% set request = guzzle(client, 'POST', 'api/0.1/test', options) %}
Response (successful)
{
"statusCode":200,
"reason":"OK",
"body":{
"credits_left":30,
"test_id":"JDHFbrt7",
"poll_state_url":"https:\/\/gtmetrix.com\/api\/0.1\/test\/JDHFbrt7"
}
}
Response (error)
{
"error":true,
"reason":"Client error: `POST https:\/\/gtmetrix.com\/api\/0.1\/test` resulted in a `401 Authorization Required` response:\n{\u0022error\u0022:\u0022Invalid e-mail and\/or API key\u0022}\n\n"
}
Guzzle Roadmap
More features soon:
Brought to you by wyveo
统计信息
- 总下载量: 53
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 8
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-08-05