rramiii
rramiii

Reputation: 1186

how to use Zend 2 Oauth package

thanx for reading, this is the first time I try to use zend 2 with Oauth, following the answer in this link I did as it said using composer but I don't know how to check if it's really installed. how can I check if it's installed? And how to use it? I tried in index controller to call it like examples in zend page

$config = array(
    'callbackUrl' => 'http://example.com/callback.php',
    'siteUrl' => 'http://twitter.com/oauth',
    'consumerKey' => 'gg3DsFTW9OU9eWPnbuPzQ',
    'consumerSecret' => 'tFB0fyWLSMf74lkEu9FTyoHXcazOWpbrAjTCCK48A'
);
$consumer = new ZendOAuth\Consumer($config);

but it returns:

Fatal error: Class 'Application\Controller\ZendOAuth\Consumer' not found

and tried to include it at the top using use command but can't find any package named Oauth. Can any one help me with this? any idea or help will be appreciated.

Upvotes: 0

Views: 262

Answers (1)

Tim Fountain
Tim Fountain

Reputation: 33148

You're within the Application\Controller namespace, so when you do new ZendOAuth\Consumer, PHP assumes you mean new Application\Controller\ZendOAuth\Consumer unless you tell it otherwise.

To fix the error, you need to do:

$consumer = new \ZendOAuth\Consumer($config);

However, you may have trouble getting this working, as I'm 80% sure the Zend OAuth package only supports OAuth 1 (it's it's just a port of the ZF1 package), not OAuth 2.

Upvotes: 3

Related Questions