Zend framework 如何将LinkedIn API与Zend_OAuth一起使用?
我正在为LinkedIn API编写一个类包装器,并使用Zend Framework 1.11.2。以下是我的一个片段:Zend framework 如何将LinkedIn API与Zend_OAuth一起使用?,zend-framework,oauth,linkedin,Zend Framework,Oauth,Linkedin,我正在为LinkedIn API编写一个类包装器,并使用Zend Framework 1.11.2。以下是我的一个片段: $config = Pb_Portal::getInstance()->getConfig('linkedin.ini'); $body = '<?xml version="1.0" encoding="UTF-8"?>'; $body .= '<share>'; $body .= '<comment>
$config = Pb_Portal::getInstance()->getConfig('linkedin.ini');
$body = '<?xml version="1.0" encoding="UTF-8"?>';
$body .= '<share>';
$body .= '<comment>83% of employers will use social media to hire: 78% LinkedIn, 55% Facebook, 45% Twitter [SF Biz Times] http://bit.ly/cCpeOD</comment>';
$body .= '<content>';
$body .= '<title>Survey: Social networks top hiring tool - San Francisco Business Times</title>';
$body .= '<submitted-url>http://sanfrancisco.bizjournals.com/sanfrancisco/stories/2010/06/28/daily34.html</submitted-url>';
$body .= '<submitted-image-url>http://images.bizjournals.com/travel/cityscapes/thumbs/sm_sanfrancisco.jpg</submitted-image-url>';
$body .= '</content>';
$body .= '<visibility>';
$body .= '<code>anyone</code>';
$body .= '</visibility>';
$body .= '</share>';
$client = Zend_Oauth::getHttpClient();
$client->setUri('http://api.linkedin.com/v1/people/~/shares');
$client->setMethod(Zend_Http_Client::POST);
$client->setRawData($body,'text/xml');
$client->setHeaders('Content-Type', 'text/xml');
$client->setParameterPost('oauth_consumer_key', $config->appKey);
$client->setParameterPost('oauth_nonce', $config->appSecretKey);
$client->setParameterPost('oauth_token', $acc->getToken());
$client->setParameterPost('oauth_timestamp', time());
$client->setParameterPost('oauth_signature_method', 'HMAC-SHA1');
$client->setParameterPost('oauth_version', '1.0');
$response = $client->request();
$xml = @simplexml_load_string($response->getBody());
我的回答是:
SimpleXMLElement Object
(
[status] => 401
[timestamp] => 1299581073233
[error-code] => 0
[message] => Unknown authentication scheme
)
有人能帮我吗?哪里出了问题?我也遇到了类似的问题(尽管我只是在检索用户信息)。这种联系帮助很大。您不需要将参数构造为get变量,而是允许令牌从您的选项构造http客户机
您可能需要更改编写类包装器的方式 你可以从这篇文章中得到想法,并在那里接受答案 祝你好运