【发布时间】:2014-01-16 08:00:09
【问题描述】:
我使用 cakephp2.x 并使用这个 Consuming OAuth-enabled APIs with CakePHP http://code.42dh.com/oauth/
我只想发推文。但我现在不能。
下载消费包并放入
app/vender/OAuth-
在 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'); 如果($requestToken){ $this->Session->write('twitter_request_token', $requestToken); $this->redirect('https://api.twitter.com/oauth/authorize?oauth_token=' . $requestToken->key); } } 公共函数回调(){ $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' => '你好世界!')); 私有函数 createClient() { return new OAuthClient('my key', 'my secret'); }
我应该在哪里更改代码??
【问题讨论】:
标签: twitter cakephp-2.0