123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126 |
- <?php
- if (!defined('STATUSNET')) {
- exit(1);
- }
- class ApiUserShowAction extends ApiPrivateAuthAction
- {
-
- protected function prepare(array $args=array())
- {
- parent::prepare($args);
- $email = $this->arg('email');
-
- if (!empty($email)) {
- $user = User::getKV('email', $email);
- } else {
- $user = $this->getTargetUser($this->arg('id'));
- }
- if (!($user instanceof User)) {
-
- $this->clientError(_('User not found.'), 404);
- }
- $this->target = $user->getProfile();
- return true;
- }
-
- protected function handle()
- {
- parent::handle();
- if (!in_array($this->format, array('xml', 'json'))) {
-
- $this->clientError(_('API method not found.'), 404);
- }
- $twitter_user = $this->twitterUserArray($this->target, true);
- if ($this->format == 'xml') {
- $this->initDocument('xml');
- $this->showTwitterXmlUser($twitter_user, 'user', true);
- $this->endDocument('xml');
- } elseif ($this->format == 'json') {
- $this->initDocument('json');
- $this->showJsonObjects($twitter_user);
- $this->endDocument('json');
- }
- }
-
- function isReadOnly($args)
- {
- return true;
- }
- }
|