<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://winkapi.quirky.com/oauth2/token");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, "{\n \"client_id\": \"consumer_key_goes_here\",\n \"client_secret\": \"consumer_secret_goes_here\",\n \"username\": \"user@example.com\",\n \"password\": \"password_goes_here\",\n \"grant_type\": \"password\"\n}");
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json"));
$response = curl_exec($ch);
curl_close($ch);
var_dump($response);
use Guzzle\Http\Client;use CommerceGuys\Guzzle\Plugin\Oauth2\Oauth2Plugin;use CommerceGuys\Guzzle\Plugin\Oauth2\GrantType\PasswordCredentials;use CommerceGuys\Guzzle\Plugin\Oauth2\GrantType\RefreshToken;
Route::get('wink', function(){
$oauth2Client = new Client('https://winkapi.quirky.com/oauth2/token'); $config = array( 'client_id' => 'xxxxxxxxxx', 'client_secret' => 'xxxxxxxxxxxxxxx', 'username' => 'ke...@xxxxxxxxxxs.com', 'password' => 'xxxxxxxx', 'grant_type' => 'password' ); $grantType = new PasswordCredentials($oauth2Client, $config); $refreshTokenGrantType = new RefreshToken($oauth2Client, $config); $oauth2Plugin = new Oauth2Plugin($grantType, $refreshTokenGrantType);
$client = new Client('https://winkapi.quirky.com'); $client->addSubscriber($oauth2Plugin); $response = $client->get('/users/me/wink_devices')->send();
var_dump($response);
});