public function get_user_info(OAuth_Consumer $consumer, OAuth_Token $token)
 {
     // Create a new GET request with the required parameters
     $request = OAuth_Request::forge('resource', 'GET', 'http://api.twitter.com/1.1/users/lookup.json', array('oauth_consumer_key' => $consumer->key, 'oauth_token' => $token->access_token, 'user_id' => $token->uid));
     // Sign the request using the consumer and token
     $request->sign($this->signature, $consumer, $token);
     $user = current(json_decode($request->execute()));
     // Create a response from the request
     return array('uid' => $token->uid, 'nickname' => $user->screen_name, 'name' => $user->name ? $user->name : $user->screen_name, 'location' => $user->location, 'image' => $user->profile_image_url, 'description' => $user->description, 'urls' => array('Website' => $user->url, 'Twitter' => 'http://twitter.com/' . $user->screen_name));
 }
 public function get_user_info(OAuth_Consumer $consumer, OAuth_Token $token)
 {
     // Create a new GET request with the required parameters
     $request = OAuth_Request::forge('resource', 'GET', 'https://api.dropbox.com/1/account/info', array('oauth_consumer_key' => $consumer->key, 'oauth_token' => $token->access_token));
     // Sign the request using the consumer and token
     $request->sign($this->signature, $consumer, $token);
     $user = json_decode($request->execute());
     // Create a response from the request
     return array('uid' => $token->uid, 'name' => $user->display_name, 'email' => $user->email, 'location' => $user->country);
 }
Exemple #3
0
 public function get_user_info(OAuth_Consumer $consumer, OAuth_Token $token)
 {
     // Create a new GET request with the required parameters
     $request = OAuth_Request::forge('resource', 'GET', 'http://api.flickr.com/services/rest', array('oauth_consumer_key' => $consumer->key, 'oauth_token' => $token->access_token, 'nojsoncallback' => 1, 'format' => 'json', 'method' => 'flickr.test.login'));
     // Sign the request using the consumer and token
     $request->sign($this->signature, $consumer, $token);
     $response = json_decode($request->execute(), true);
     // Create a response from the request
     return array('uid' => $response['user']['id'], 'name' => $response['user']['username']['_content'], 'nickname' => $response['user']['username']['_content']);
 }
Exemple #4
0
 public function get_user_info(OAuth_Consumer $consumer, OAuth_Token $token)
 {
     // Create a new GET request with the required parameters
     $url = 'https://api.linkedin.com/v1/people/~:(id,first-name,last-name,headline,member-url-resources,picture-url,location,public-profile-url)';
     $request = OAuth_Request::forge('resource', 'GET', $url, array('oauth_consumer_key' => $consumer->key, 'oauth_token' => $token->access_token));
     // Sign the request using the consumer and token
     $request->sign($this->signature, $consumer, $token);
     $user = OAuth_Format::factory($request->execute(), 'xml')->to_array();
     // Create a response from the request
     return array('uid' => $user['id'], 'name' => $user['first-name'] . ' ' . $user['last-name'], 'nickname' => end(explode('/', $user['public-profile-url'])), 'description' => $user['headline'], 'location' => isset($user['location']['name']) ? $user['location']['name'] : null, 'urls' => array('Linked In' => $user['public-profile-url']));
 }
 public function get_user_info(OAuth_Consumer $consumer, OAuth_Token $token)
 {
     // Create a new GET request with the required parameters
     $request = OAuth_Request::forge('resource', 'GET', 'http://api.flickr.com/services/rest', array('oauth_consumer_key' => $consumer->key, 'oauth_token' => $token->access_token, 'nojsoncallback' => 1, 'format' => 'json', 'user_id' => $token->uid, 'method' => 'flickr.people.getInfo'));
     // Sign the request using the consumer and token
     $request->sign($this->signature, $consumer, $token);
     $response = json_decode($request->execute(), true);
     $user = $response['person'];
     // Create a response from the request
     return array('uid' => $user['nsid'], 'name' => isset($user['realname']['_content']) ? $user['realname']['_content'] : $user['username']['_content'], 'nickname' => $user['username']['_content'], 'location' => isset($user['location']['_content']) ? $user['location']['_content'] : NULL, 'image' => $user['iconserver'] ? "http://farm{$user['iconfarm']}.staticflickr.com/{$user['iconserver']}/buddyicons/{$user['nsid']}.jpg" : NULL, 'urls' => array('photos' => $user['photosurl']['_content'], 'profile' => $user['profileurl']['_content']));
 }
 public function get_user_info(OAuth_Consumer $consumer, OAuth_Token $token)
 {
     // Create a new GET request with the required parameters
     $request = OAuth_Request::forge('resource', 'GET', 'http://api.tumblr.com/v2/user/info', array('oauth_consumer_key' => $consumer->key, 'oauth_token' => $token->access_token));
     // Sign the request using the consumer and token
     $request->sign($this->signature, $consumer, $token);
     $response = json_decode($request->execute());
     $status = current($response);
     $response = next($response);
     $user = $response->user;
     // Create a response from the request
     return array('uid' => $user->name, 'name' => $user->name, 'likes' => $user->likes, 'following' => $user->following, 'default_post_format' => $user->default_post_format);
 }
 /**
  * Exchange the request token for an access token.
  *
  *     $token = $provider->access_token($consumer, $token);
  *
  * @param   Consumer       consumer
  * @param   Token_Request  token
  * @param   array                additional request parameters
  * @return  Token_Access
  */
 public function access_token(OAuth_Consumer $consumer, OAuth_Token_Request $token, array $params = NULL)
 {
     // Create a new GET request for a request token with the required parameters
     $request = OAuth_Request::forge('access', 'GET', $this->url_access_token(), array('oauth_consumer_key' => $consumer->key, 'oauth_token' => $token->access_token, 'oauth_verifier' => $token->verifier));
     if ($params) {
         // Load user parameters
         $request->params($params);
     }
     // Sign the request using only the consumer, no token is available yet
     $request->sign($this->signature, $consumer, $token);
     // Create a response from the request
     $response = $request->execute();
     // Store this token somewhere useful
     return OAuth_Token::forge('access', array('access_token' => $response->param('oauth_token'), 'secret' => $response->param('oauth_token_secret'), 'uid' => $response->param($this->uid_key) ?: get_instance()->input->get_post($this->uid_key)));
 }