回答 + 新しい質問
以下のコードが LIVE サーバーで問題なく動作することがわかりました。LinkedIN は、localhost からのすべてのリクエストをブロックしました。
それが確立されました。LinkedIN OAuth を使用して localhost からアプリケーションをテストする方法を知っている人はいますか? ライブサーバーでこれを行うのは最悪だからです!
古い質問
Zend_OAuth で LinkedIN に接続しようとしています。このコードは以前は機能していましたが、アクセス トークンを取得しようとすると、http 要求でエラーが返されます。
LinkedIN api をチェックしようとしましたが、コードはまだ有効なようです。いくつかのスクリプトを試しましたが、すべて同じ結果になりました。
構成は、コントローラーの preDispatch でセットアップされます
$this->configLinkedin = array(
'version' => '1.0',
'siteUrl' => 'http://'.$_SERVER['HTTP_HOST'].$this->view->baseUrl(false).'/news/index/connectlinkedin',
'callbackUrl' => 'http://'.$_SERVER['HTTP_HOST'].$this->view->baseUrl(false).'/news/index/connectlinkedin',
'requestTokenUrl' => 'https://api.linkedin.com/uas/oauth/requestToken',
'userAuthorisationUrl' => 'https://api.linkedin.com/uas/oauth/authorize',
'accessTokenUrl' => 'https://api.linkedin.com/uas/oauth/accessToken',
'consumerKey' => 'XXX',
'consumerSecret' => 'XXX'
);
そして、linkedIN に接続するアクションのコードは次のとおりです。
$this->consumer = new Zend_Oauth_Consumer($this->configLinkedin);
if(!empty($_GET) && isset($_SESSION['LINKEDIN_REQUEST_TOKEN']))
{
$token = $this->consumer->getAccessToken($_GET, unserialize($_SESSION['LINKEDIN_REQUEST_TOKEN']));
// Use HTTP Client with built-in OAuth request handling
$client = $token->getHttpClient($this->configLinkedin);
// Set LinkedIn URI
$client->setUri('https://api.linkedin.com/v1/people/~:(id,first-name,last-name,picture-url)');
// Set Method (GET, POST or PUT)
$client->setMethod(Zend_Http_Client::GET);
// Get Request Response
$response = $client->request();
$this->NewsService->TokenSocialMedia(
$token,
'linkedin',
serialize($response->getBody())
);
$_SESSION['LINKEDIN_REQUEST_TOKEN'] = null;
$this->_helper->flashMessenger(array('message' => $this->view->translate('The CMS is successfully connected to your linkedin account'), 'status' => 'success'));
$this->_helper->redirector('settings#settingSocial', 'index');
}
else
{
$token = $this->consumer->getRequestToken();
$_SESSION['LINKEDIN_REQUEST_TOKEN'] = serialize($token);
$this->consumer->redirect();
}
私は何が欠けているか、間違っていますか? 私は Twitter に同様の設定を使用していますが、問題なく動作します。
2011 年 9 月 20 日更新
このルールがエラーを返すことがわかりました:
$token = $this->consumer->getRequestToken();
理由はまだわかりません.linkedin APIを読んでも少しは役に立ちません. お知らせします。