I'm using the Yahoo! Social SDK to allow a user to authorize and then get a list of their contacts. I've setup the app to allow for the contact data to be read and this is verified when authenticating.
The authentication works because I can the profile using getProfile()
on every single page load. The getContacts()
is the problem though as 95% of the time it returns false which is not correct.
Am I doing something wrong with the request tokens that means getContacts()
doesn't have the correct permission to run successfully or do Yahoo have some sort of strange caching issue with this query? It's even harder with the distinct lack of documentation from them regarding their api and php, is there another new library I can use to achieve this? I know it's possible because I can use a working version on the "AirBnb Invite a friend" webpage.
This is the code I'm using, it's written using CodeIgniter so that explains the syntax.
public function yahoo() {
$oauthapp = new YahooOAuthApplication(DEV_OAUTH_CONSUMER_KEY, DEV_OAUTH_CONSUMER_SECRET, DEV_OAUTH_APP_ID, DEV_OAUTH_DOMAIN);
if($this->session->userdata('yahoo_oauth_access_token')){
$oauthapp->token = YahooOAuthAccessToken::from_string($this->session->userdata('yahoo_oauth_access_token'));
$profile = $oauthapp->getProfile();
$contacts = $oauthapp->getContacts(0, 1000);
if($profile)
print_r($profile);
else
echo "No profile / error";
if($contacts)
print_r($contacts);
else
echo "No contacts / error";
}
elseif(!$this->input->get()) {
$request_token = $oauthapp->getRequestToken(DEV_OAUTH_DOMAIN);
$this->session->set_userdata('request_token', json_encode($request_token));
$redirect_url = $oauthapp->getAuthorizationUrl($request_token);
redirect($redirect_url);
}
else {
$request_token = json_decode($this->session->userdata('request_token'));
$oauthapp->token = $oauthapp->getAccessToken($request_token, $this->input->get('oauth_verifier'));
$this->session->set_userdata('yahoo_oauth_access_token', $oauthapp->token->to_string());
redirect("/index/yahoo");
}
}