oauth-4-laravel
oauth-4-laravel copied to clipboard
Failed to request resource.
use OAuth\Common\Storage\Session as S;
class AuthController extends BaseController { public function getIndex() { $code = Input::get('oauth_token'); $twitterservice = OAuth::consumer('Twitter'); $storage = new S();
if (!empty($code)) {
$token = $storage->retrieveAccessToken('Twitter');
$twitterservice->requestAccessToken(
Input::get('oauth_token'),
Input::get('oauth_verifier'),
$token->getRequestTokenSecret()
);
$result = json_decode($twitterservice->request('account/verify_credentials'));
echo 'result: <pre>' . print_r($result, true) . '</pre>';
}
i always get error 'Failed to request resource'
help me please..
Just follow the example in the README, this one works for me:
Since you're using Input::get('oauth_token')
and Input::get('oauth_verifier')
, I don't understand why you try to use the session access token too?
$token = Input::get( 'oauth_token' );
$verify = Input::get( 'oauth_verifier' );
// get twitter service
$tw = OAuth::consumer( 'Twitter' );
if ( !empty( $token ) && !empty( $verify ) ) {
// This was a callback request from twitter, get the token
$token = $tw->requestAccessToken( $token, $verify );
// Send a request with it
$result = json_decode( $tw->request( 'account/verify_credentials.json' ), true );
var_dump($result);
}
Thanks for your concern... I'm sorry i thought it must used session access token... But if you say that.. I will fix it.
Thank you On Jul 26, 2014 9:37 PM, "i3zhe" [email protected] wrote:
Just follow the example in the README, this one works for me: Since you're using Input::get('oauth_token') and Input::get('oauth_verifier'), I don't understand why you try to use the session access token too?
$token = Input::get( 'oauth_token' );$verify = Input::get( 'oauth_verifier' ); // get twitter service$tw = OAuth::consumer( 'Twitter' ); if ( !empty( $token ) && !empty( $verify ) ) {
// This was a callback request from twitter, get the token $token = $tw->requestAccessToken( $token, $verify ); // Send a request with it $result = json_decode( $tw->request( 'account/verify_credentials.json' ), true ); var_dump($result);}
— Reply to this email directly or view it on GitHub https://github.com/artdarek/oauth-4-laravel/issues/84#issuecomment-50235779 .
Sorry, I might be wrong. The session token should be an option, not required.