Have a GET Request with HMAC-SHA1 signature method instead of POST Request with PLAINTEXT signature method would solve this issue. I tried with PHP using zend oauth. I got the contacts.
Zend code.
/**
* Sample method - Delete it once integrated with contacts import
*/
public function getyahoocontactsAction() {
if (($oauth = $this->getRequest()->getParam('oauth_token', false)) !== false) {
$session = new Zend_Session_Namespace("yahoo");
if ($session->request_token) {
$token = unserialize($session->request_token);
if ($token && ($token->getToken() == $oauth)) {
$config = array(
'callbackUrl' => $this->view->currentBaseUrl . $this->view->url(array('controller' => 'controller_name', 'action'=>'getyahoocontacts'), 'default', true),
'siteUrl' => 'https://api.login.yahoo.com/oauth/v2',
'consumerKey' => 'Your consumer key',
'consumerSecret' => 'Consumer secret key',
'accessTokenUrl' => 'https://api.login.yahoo.com/oauth/v2/get_token',
'requestScheme' => Zend_Oauth::REQUEST_SCHEME_QUERYSTRING,
'requestMethod' => Zend_Oauth::GET,
'signatureMethod' => 'HMAC-SHA1',
'version' => '1.0'
);
$consumer = new Zend_Oauth_Consumer($config);
$accessToken = $consumer->getAccessToken($_GET, $token);
$session->access_token = serialize($accessToken);
$session->request_token = null;
$client = $accessToken->getHttpClient($config, 'http://social.yahooapis.com/v1/user/' . $accessToken->getParam('xoauth_yahoo_guid') . '/contacts');
$client->setMethod(Zend_Http_Client::GET);
$response = $client->request();
header('Content-Type: ' . $response->getHeader('Content-Type'));
Propel_Helper::log($response->getBody()); exit;
}
else {
$this->_redirect($this->view->url(array('controller'=>'controller_name', 'action' => 'list'), 'default', true));
}
}
else {
$this->_redirect($this->view->url(array('controller'=>'controller_name', 'action' => 'list'), 'default', true));
}
}
else {
$config = array(
'callbackUrl' => $this->view->currentBaseUrl . $this->view->url(array('controller' => 'controller_name', 'action'=>'getyahoocontacts'), 'default', true),
'siteUrl' => 'https://api.login.yahoo.com/oauth/v2',
'consumerKey' => 'consumer key',
'consumerSecret' => 'secret key',
'requestTokenUrl' => 'https://api.login.yahoo.com/oauth/v2/get_request_token',
'userAuthorizationUrl' => 'https://api.login.yahoo.com/oauth/v2/request_auth',
'requestScheme' => Zend_Oauth::REQUEST_SCHEME_QUERYSTRING,
'requestMethod' => Zend_Oauth::GET,
'signatureMethod' => 'HMAC-SHA1',
'version' => '1.0'
);
$consumer = new Zend_Oauth_Consumer($config);
$token = $consumer->getRequestToken();
Propel_Helper::log(serialize($token));
$session = new Zend_Session_Namespace("yahoo");
$session->request_token = serialize($token);
$consumer->redirect();
}
}
Hope it will be helpful.
QUOTE(Goran Zivkovic @ 1 Jun 2011 12:59 PM)
I got my Contacts call to work fine, after some serious looking over the code. What was wrong with mine was that my access token was saved as a string in the table, and not a text (since yahoo's keys are insanely long). When I tried to call the API I would get the signature_invalid error because my base string was missing most of my oauth_token in it.
See if this is the problem.
Right now my problem is that the xml response returned only contains the names. guids, and cids, of the contacts, and not the email, birthday, etc. Which is driving me insane because I made two accounts with everything visible to my Connections, and still nadda.
Anyways, hope I could help.