public function get_user_info(Token $token, Consumer $consumer) { // Create a new GET request with the required parameters $request = Request::make('resource', 'GET', 'https://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->screen_name, 'location' => $user->location, 'image' => $user->profile_image_url, 'description' => $user->description, 'urls' => array('website' => $user->url, 'twitter' => 'https://twitter.com/' . $user->screen_name)); }
public function get_user_info(Token $token, Consumer $consumer) { // Create a new GET request with the required parameters $request = Request::make('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' => array_get($response, 'user.id'), 'name' => array_get($response, 'user.username._content'), 'nickname' => array_get($response, 'user.username._content')); }
public function get_user_info(Token $token, Consumer $consumer) { // Create a new GET request with the required parameters $request = Request::make('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, 'location' => $user->country); }
public function get_user_info(Token $token, Consumer $consumer) { // Create a new GET request with the required parameters $request = Request::make('resource', 'GET', 'http://vimeo.com/api/rest/v2/', array('method' => 'vimeo.people.getInfo', 'oauth_consumer_key' => $consumer->key, 'oauth_token' => $token->access_token, 'format' => 'json')); // Sign the request using the consumer and token $request->sign($this->signature, $consumer, $token); $response = json_decode($request->execute()); $user = $response->person; $profile_image = end($user->portraits->portrait); $url = current($user->url); // Create a response from the request return array('uid' => $user->id, 'nickname' => $user->username, 'name' => $user->display_name ?: $user->username, 'location' => $user->location, 'image' => $profile_image->_content, 'description' => $user->bio, 'urls' => array('website' => $url, 'vimeo' => $user->profileurl)); }
public function get_user_info(Token $token, Consumer $consumer) { // Create a new GET request with the required parameters $request = Request::make('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); }
public function get_user_info(Token $token, Consumer $consumer) { // 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)?format=json'; $request = Request::make('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 = json_decode($request->execute(), true); $nickname = null; // Split the profile url to get the user's nickname if ($linked_url = array_get($user, 'publicProfileUrl')) { $profile_nickname = explode('/', $linked_url); $nickname = end($profile_nickname); } // Create a response from the request return array('uid' => array_get($user, 'id'), 'name' => array_get($user, 'firstName') . ' ' . array_get($user, 'lastName'), 'image' => array_get($user, 'pictureUrl'), 'nickname' => $nickname, 'description' => array_get($user, 'headline'), 'location' => array_get($user, 'location.name'), 'urls' => array('linkedin' => $linked_url)); }
/** * 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(Token\Request $token, Consumer $consumer, array $params = null) { // Create a new GET request for a request token with the required // parameters $request = Request::make('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 Token::make('access', array('access_token' => $response->param('oauth_token'), 'secret' => $response->param('oauth_token_secret'), 'uid' => $response->param($this->uid_key) ?: Input::get($this->uid_key))); }