Zend Framework - Oauth - Get LinkedInContacts
Get a request token
/* Set up the Oauth consumer */
$oauth = new Zend_Oauth_Consumer(array(
'consumerKey' => $this->configs->connections->consumerKey,
'consumerSecret' => $this->configs->connections->consumerSecret));
$oauth->setRequestTokenUrl($this->configs->token_uri);
/* Get the request token */
$token = $oauth->getRequestToken();
/* This is the URI to allow the user to authorize access */
$auth_uri = $token->xoauth_request_auth_url.'?oauth_token='.urlencode($token->oauth_token);
/* Save the request token */
$session=new Zend_Session_Namespace('linkedin_connections');
$session->token = serialize($token);
Get the OAuth token and token secret for the user
/* Set up the OAuth consumer */
$oauth = new Zend_Oauth_Consumer(array(
'consumerKey' => $this->configs->connections->consumerKey,
'consumerSecret' => $this->configs->connections->consumerSecret));
$oauth->setAccessTokenUrl($this->configs->access_uri);
/* Get the request token */
$session=new Zend_Session_Namespace('linkedin_connections');
$token = unserialize($session->token);
/* Get the access token and token secret */
$token = $oauth->getAccessToken(
array('oauth_token' => $token->oauth_token,
'oauth_token_secret' => $token->oauth_token_secret,
'oauth_verifier' => $data['auth_code']),
$token,Zend_Oauth_Consumer::POST);
$response = $token->getResponse();
$this->linkedinconnections_data->oauth_token = $token->oauth_token;
$this->linkedinconnections_data->oauth_token_secret = $token->oauth_token_secret;
$this->linkedinconnections_data->oauth_expires_in = $token->oauth_expires_in;
$this->linkedinconnections_data->oauth_authorization_expires_in = $token->oauth_authorization_expires_in;
Get the connections
/* Set up the Oauth client */
$oauth = new Zend_Oauth_Client(array(
'consumerKey' => $this->configs->connections->consumerKey,
'consumerSecret' => $this->configs->connections->consumerSecret),$this->configs->connections_uri);
/* Set up the tokens for the user */
$token = new Zend_Oauth_Token_Access();
$token->setToken($this->linkedinconnections_data->oauth_token);
$token->setTokenSecret($this->linkedinconnections_data->oauth_token_secret);
/* Set the tokens for the client */
$oauth->setToken($token);
$oauth->setMethod(Zend_Oauth_Client::GET);
/* Make the request */
$response = $oauth->request();
Zend Framework Version 1.11
Print article | This entry was posted by elvis on 11/30/11 at 02:49:00 pm . Follow any responses to this post through RSS 2.0. |