Created
December 27, 2011 11:25
-
-
Save nanofi/1523354 to your computer and use it in GitHub Desktop.
http://d.hatena.ne.jp/nanofi/20111227/1324983161 The implement of userinfo service for google-api-php-client. http://code.google.com/p/google-api-php-client/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require_once 'service/apiModel.php'; | |
require_once 'service/apiService.php'; | |
require_once 'service/apiServiceRequest.php'; | |
class UserinfoServiceResource extends apiServiceResource { | |
public function get($optParams = array()) { | |
$params = array(); | |
$params = array_merge($params, $optParams); | |
$data = $this->__call('get', array($params)); | |
if ($this->useObjects()) { | |
return new Userinfo($data); | |
} else { | |
return $data; | |
} | |
} | |
} | |
class apiUserinfoService extends apiService { | |
public $userinfo; | |
/** | |
* Constructs the internal representation of the Userinfo service. | |
* | |
* @param apiClient apiClient | |
*/ | |
public function __construct(apiClient $apiClient) { | |
$this->rpcPath = '/rpc'; | |
$this->restBasePath = '/oauth2/v1/'; | |
$this->version = 'v1'; | |
$this->serviceName = 'userinfo'; | |
$this->io = $apiClient->getIo(); | |
$apiClient->addService($this->serviceName, $this->version); | |
$this->userinfo = new UserinfoServiceResource($this, $this->serviceName, 'userinfo', json_decode('{"methods": {"get": {"scopes": ["https://www.googleapis.com/auth/userinfo.profile", "https://www.googleapis.com/auth/userinfo.email"], "parameters": {}, "id": "userinfo.get", "httpMethod": "GET", "path": "userinfo", "response": {"ref": "Userinfo"}}}}', true)); | |
} | |
} | |
class Userinfo extends apiModel { | |
public $id; | |
public $email; | |
public $verified_email; | |
public $name; | |
public $given_name; | |
public $family_name; | |
public $picture; | |
public $locale; | |
public $timezone; | |
public $gender; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment