I use cakephp2.x and use this Consuming OAuth-enabled APIs with CakePHP
http://code.42dh.com/oauth/
I only want to be able to tweet. But I can't now.
Download consuming package and put
app/vender/OAuth
Write this code in PostsController
App::import('Vendor', 'OAuth/OAuthClient');
public function add() { $client = $this->createClient(); $requestToken = $client->getRequestToken('https://api.twitter.com/oauth/request_token',
'http://' . $_SERVER['HTTP_HOST'] . '/lolch/posts'); if ($requestToken) { $this->Session->write('twitter_request_token', $requestToken); $this->redirect('https://api.twitter.com/oauth/authorize?oauth_token=' . $requestToken->key); } } public function callback() { $requestToken = $this->Session->read('twitter_request_token'); $client = $this->createClient(); $accessToken = $client->getAccessToken('https://api.twitter.com/oauth/access_token', $requestToken); $client->post($accessToken->key, $accessToken->secret, 'https://api.twitter.com/1.1/statuses/update.json', array('status' => 'hello world!')); private function createClient() { return new OAuthClient('my key', 'my secret'); }
Where should I change the code??