Created
August 31, 2011 23:09
-
-
Save kiall/1185010 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php defined('SYSPATH') or die('No direct script access.'); | |
/** | |
* | |
* | |
* @package MIP Website | |
* @category Controller | |
* @author Managed I.T. | |
* @copyright (c) 2011 Managed I.T. | |
*/ | |
class Controller_Test extends Controller { | |
public function action_index() | |
{ | |
$user_id = 1; | |
$client = OAuth2_Consumer::factory('mip', $user_id); | |
try | |
{ | |
$request = Request::factory('http://wk01-lmst.managedit.ie/mip-api/api/roles'); | |
$response = $client->execute($request); | |
echo Debug::vars($response); | |
} | |
catch (OAuth2_Exception_InvalidGrant $e) | |
{ | |
/** | |
* This means the request failed due to bad credentials. | |
*/ | |
} | |
catch (OAuth2_Exception_InvalidToken $e) | |
{ | |
/** | |
* This means we dont have a token, we need to get one before we can retry. | |
*/ | |
$client->request_token($user_id, array( | |
'username' => 'kiall', | |
'password' => 'password', | |
)); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment