dukt / rest
REST plugin for Craft CMS
Installs: 14
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 4
Forks: 2
Type:craft-plugin
README
Perform authenticated REST requests
Table of Contents
Installing and updating
Requirements
- Craft 2.5
- Craft OAuth 1.0
Installation
- Download the latest release of the plugin
- Drop the
rest
plugin folder tocraft/plugins
- Install REST plugin from the control panel in
Settings > Plugins
Updating
- Download the latest release of the plugin
- Replace the
rest
plugin folder by the new one undercraft/plugins
- Access your Craft control panel. You might be prompted to "Finish Up" the update if one or more migrations need to be applied.
Requests
Simple Request
{% set response = craft.rest.request.url('http://api.openweathermap.org/data/2.5/weather?q=London,uk&appid=2de143494c0b295cca9337e1e96b00e0').send() %}
<pre>{{ dump(response) }}</pre>
Query Parameters
{% set response = craft.rest.request
.url('http://api.openweathermap.org/data/2.5/weather')
.query({
q: 'London,uk',
appid: '2de143494c0b295cca9337e1e96b00e0',
})
.send() %}
Authentication
{% set response = craft.rest.request
.authentication('youtube')
.url('https://www.googleapis.com/youtube/v3/search')
.query({
part: 'snippet',
q: 'timelapse',
})
.send() %}
Token
{% set response = craft.oauth.getTokenById(123) %}
{% set response = craft.rest.request
.token(token)
.url('https://www.googleapis.com/youtube/v3/search')
.query({
part: 'snippet',
q: 'timelapse',
})
.send() %}
Authentications
Supported Providers
You can set up authentication with any OAuth provider provided by the OAuth plugin:
- GitHub
- Slack
- Vimeo
The plugin also supports any third party OAuth providers supported by the OAuth plugin.
Dukt.net © 2017 - All rights reserved