コード例 #1
0
ファイル: apiusershow.php プロジェクト: Br3nda/StatusNet
 /**
  * Handle the request
  *
  * Check the format and show the user info
  *
  * @param array $args $_REQUEST data (unused)
  *
  * @return void
  */
 function handle($args)
 {
     parent::handle($args);
     if (empty($this->user)) {
         $this->clientError(_('Not found.'), 404, $this->format);
         return;
     }
     if (!in_array($this->format, array('xml', 'json'))) {
         $this->clientError(_('API method not found.'), $code = 404);
         return;
     }
     $profile = $this->user->getProfile();
     if (empty($profile)) {
         $this->clientError(_('User has no profile.'));
         return;
     }
     $twitter_user = $this->twitterUserArray($this->user->getProfile(), 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');
     }
 }
コード例 #2
0
 /**
  * Handle the request
  *
  * Show the profiles
  *
  * @return void
  */
 protected function handle()
 {
     parent::handle();
     $this->initDocument('json');
     print json_encode($this->showProfiles());
     $this->endDocument('json');
 }
コード例 #3
0
ファイル: apigrouplistall.php プロジェクト: Br3nda/StatusNet
 /**
  * Handle the request
  *
  * Show the user's groups
  *
  * @param array $args $_REQUEST data (unused)
  *
  * @return void
  */
 function handle($args)
 {
     parent::handle($args);
     $sitename = common_config('site', 'name');
     // TRANS: Message is used as a title. %s is a site name.
     $title = sprintf(_("%s groups"), $sitename);
     $taguribase = TagURI::base();
     $id = "tag:{$taguribase}:Groups";
     $link = common_local_url('groups');
     $subtitle = sprintf(_("groups on %s"), $sitename);
     switch ($this->format) {
         case 'xml':
             $this->showXmlGroups($this->groups);
             break;
         case 'rss':
             $this->showRssGroups($this->groups, $title, $link, $subtitle);
             break;
         case 'atom':
             $selfuri = common_root_url() . 'api/statusnet/groups/list_all.atom';
             $this->showAtomGroups($this->groups, $title, $id, $link, $subtitle, $selfuri);
             break;
         case 'json':
             $this->showJsonGroups($this->groups);
             break;
         default:
             $this->clientError(_('API method not found.'), 404, $this->format);
             break;
     }
 }
コード例 #4
0
ファイル: apiusershow.php プロジェクト: Grasia/bolotweet
 /**
  * Handle the request
  *
  * Check the format and show the user info
  *
  * @param array $args $_REQUEST data (unused)
  *
  * @return void
  */
 function handle($args)
 {
     parent::handle($args);
     if (empty($this->user)) {
         // TRANS: Client error displayed when requesting user information for a non-existing user.
         $this->clientError(_('User not found.'), 404, $this->format);
         return;
     }
     if (!in_array($this->format, array('xml', 'json'))) {
         // TRANS: Client error displayed when coming across a non-supported API method.
         $this->clientError(_('API method not found.'), $code = 404);
         return;
     }
     $profile = $this->user->getProfile();
     if (empty($profile)) {
         // TRANS: Error message displayed when referring to a user without a profile.
         $this->clientError(_('User has no profile.'));
         return;
     }
     $twitter_user = $this->twitterUserArray($this->user->getProfile(), 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');
     }
 }
コード例 #5
0
 /**
  * Handle the request
  *
  * Check the format and show the user info
  *
  * @param array $args $_REQUEST data (unused)
  *
  * @return void
  */
 protected function handle()
 {
     parent::handle();
     $twitter_user = $this->twitterUserArray($this->profile, true);
     $this->initDocument('json');
     $this->showJsonObjects($twitter_user);
     $this->endDocument('json');
 }
コード例 #6
0
 /**
  * Handle the request
  *
  * Check the format and show the user info
  *
  * @return void
  */
 protected function handle()
 {
     parent::handle();
     $size = $this->avatarSize();
     $url = $this->target->avatarUrl($size);
     // We don't actually output JSON or XML data -- redirect!
     common_redirect($url, 302);
 }
コード例 #7
0
 /**
  * Handle the request
  *
  * Just show the notices
  *
  * @param array $args $_REQUEST data (unused)
  *
  * @return void
  */
 function handle($args)
 {
     parent::handle($args);
     if (empty($this->group)) {
         $this->clientError(_('Group not found.'), 404, $this->format);
         return false;
     }
     $this->notices = $this->getNotices();
     $this->showTimeline();
 }
コード例 #8
0
 /**
  * Handle the request
  *
  * Just show the notices
  *
  * @return void
  */
 protected function handle()
 {
     parent::handle();
     if (empty($this->group)) {
         // TRANS: Client error displayed requesting most recent notices to a group for a non-existing group.
         $this->clientError(_('Group not found.'), 404);
     }
     $this->notices = $this->getNotices();
     $this->showTimeline();
 }
コード例 #9
0
 /**
  * Handle the request
  *
  * Just show the notices
  *
  * @return void
  */
 protected function handle()
 {
     parent::handle();
     if (empty($this->list)) {
         // TRANS: Client error displayed trying to perform an action related to a non-existing list.
         $this->clientError(_('List not found.'), 404);
     }
     $this->getNotices();
     $this->showTimeline();
 }
コード例 #10
0
 /**
  * Handle the request
  *
  * Check the format and show the user info
  *
  * @return void
  */
 protected function handle()
 {
     parent::handle();
     switch ($this->format) {
         case 'xml':
             $this->showSingleXmlGroup($this->group);
             break;
         case 'json':
             $this->showSingleJsonGroup($this->group);
             break;
         default:
             // TRANS: Client error displayed when coming across a non-supported API method.
             $this->clientError(_('API method not found.'), 404);
     }
 }
コード例 #11
0
 /**
  * Handle the request
  *
  * @param array $args $_REQUEST data (unused)
  *
  * @return void
  */
 function handle($args)
 {
     parent::handle($args);
     if ($this->format == 'xml') {
         $this->initDocument('xml');
         $this->element('ok', null, 'true');
         $this->endDocument('xml');
     } elseif ($this->format == 'json') {
         $this->initDocument('json');
         print '"ok"';
         $this->endDocument('json');
     } else {
         $this->clientError(_('API method not found.'), 404, $this->format);
     }
 }
コード例 #12
0
 /**
  * Handle the request
  *
  * Show the members of the group
  *
  * @param array $args $_REQUEST data (unused)
  *
  * @return void
  */
 function handle($args)
 {
     parent::handle($args);
     // XXX: RSS and Atom
     switch ($this->format) {
         case 'xml':
             $this->showTwitterXmlUsers($this->profiles);
             break;
         case 'json':
             $this->showJsonUsers($this->profiles);
             break;
         default:
             $this->clientError(_('API method not found.'), 404, $this->format);
             break;
     }
 }
コード例 #13
0
 /**
  * Handle the request
  *
  * Show the members of the group
  *
  * @return void
  */
 protected function handle()
 {
     parent::handle();
     // XXX: RSS and Atom
     switch ($this->format) {
         case 'xml':
             $this->showTwitterXmlUsers($this->profiles);
             break;
         case 'json':
             $this->showJsonUsers($this->profiles);
             break;
         default:
             // TRANS: Client error displayed when coming across a non-supported API method.
             $this->clientError(_('API method not found.'), 404);
     }
 }
コード例 #14
0
 /**
  * Handle the request
  *
  * Check the format and show the user info
  *
  * @return void
  */
 protected function handle()
 {
     parent::handle();
     if (!in_array($this->format, array('xml', 'json'))) {
         // TRANS: Client error displayed when coming across a non-supported API method.
         $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');
     }
 }
コード例 #15
0
 protected function handle()
 {
     parent::handle();
     switch ($this->format) {
         case 'xml':
             $this->initDocument('xml');
             $this->element('version', null, GNUSOCIAL_VERSION);
             $this->endDocument('xml');
             break;
         case 'json':
             $this->initDocument('json');
             print '"' . GNUSOCIAL_VERSION . '"';
             $this->endDocument('json');
             break;
         default:
             // TRANS: Client error displayed when coming across a non-supported API method.
             $this->clientError(_('API method not found.'), 404);
     }
 }
コード例 #16
0
 /**
  * Handle the request
  *
  * @param array $args $_REQUEST data (unused)
  *
  * @return void
  */
 function handle($args)
 {
     parent::handle($args);
     switch ($this->format) {
         case 'xml':
             $this->initDocument('xml');
             $this->element('version', null, STATUSNET_VERSION);
             $this->endDocument('xml');
             break;
         case 'json':
             $this->initDocument('json');
             print '"' . STATUSNET_VERSION . '"';
             $this->endDocument('json');
             break;
         default:
             $this->clientError(_('API method not found.'), 404, $this->format);
             break;
     }
 }
コード例 #17
0
 /**
  * Handle the request
  *
  * Show the members of the group
  *
  * @param array $args $_REQUEST data (unused)
  *
  * @return void
  */
 function handle($args)
 {
     parent::handle($args);
     if (empty($this->group)) {
         // TRANS: Client error displayed trying to show group membership on a non-existing group.
         $this->clientError(_('Group not found.'), 404, $this->format);
         return false;
     }
     // XXX: RSS and Atom
     switch ($this->format) {
         case 'xml':
             $this->showTwitterXmlUsers($this->profiles);
             break;
         case 'json':
             $this->showJsonUsers($this->profiles);
             break;
         default:
             $this->clientError(_('API method not found.'), 404, $this->format);
             break;
     }
 }
コード例 #18
0
 /**
  * Handle the request
  *
  * Check the format and show the user info
  *
  * @return void
  */
 protected function handle()
 {
     parent::handle();
     if (empty($this->profile_a) || empty($this->profile_b)) {
         $this->clientError(_('Two valid IDs or nick names must be supplied.'), 400);
     }
     $result = Subscription::exists($this->profile_a, $this->profile_b);
     switch ($this->format) {
         case 'xml':
             $this->initDocument('xml');
             $this->element('friends', null, $result);
             $this->endDocument('xml');
             break;
         case 'json':
             $this->initDocument('json');
             print json_encode($result);
             $this->endDocument('json');
             break;
         default:
             break;
     }
 }
コード例 #19
0
 /**
  * Handle the request
  *
  * Check the format and show the user info
  *
  * @param array $args $_REQUEST data (unused)
  *
  * @return void
  */
 function handle($args)
 {
     parent::handle($args);
     if (empty($this->user_a) || empty($this->user_b)) {
         $this->clientError(_('Two user ids or screen_names must be supplied.'), 400, $this->format);
         return;
     }
     $result = $this->user_a->isSubscribed($this->user_b);
     switch ($this->format) {
         case 'xml':
             $this->initDocument('xml');
             $this->element('friends', null, $result);
             $this->endDocument('xml');
             break;
         case 'json':
             $this->initDocument('json');
             print json_encode($result);
             $this->endDocument('json');
             break;
         default:
             break;
     }
 }
コード例 #20
0
 /**
  * Handle the request
  *
  * Check the format and show the user info
  *
  * @param array $args $_REQUEST data (unused)
  *
  * @return void
  */
 function handle($args)
 {
     parent::handle($args);
     if (empty($this->user)) {
         // TRANS: Client error displayed when requesting user information for a non-existing user.
         $this->clientError(_('User not found.'), 404, $this->format);
         return;
     }
     $profile = $this->user->getProfile();
     if (empty($profile)) {
         // TRANS: Client error displayed when requesting user information for a user without a profile.
         $this->clientError(_('User has no profile.'));
         return;
     }
     $size = $this->avatarSize();
     $avatar = $profile->getAvatar($size);
     if ($avatar) {
         $url = $avatar->displayUrl();
     } else {
         $url = Avatar::defaultImage($size);
     }
     // We don't actually output JSON or XML data -- redirect!
     common_redirect($url, 302);
 }
コード例 #21
0
 /**
  * Handle the request
  *
  * Just show the notices
  *
  * @param array $args $_REQUEST data (unused)
  *
  * @return void
  */
 protected function handle()
 {
     parent::handle();
     $this->showTimeline();
 }
コード例 #22
0
 /**
  * Handle the request
  *
  * Check the format and show the user info
  *
  * @param array $args $_REQUEST data (unused)
  *
  * @return void
  */
 protected function handle()
 {
     parent::handle();
     // since this api method is in practice only used when expanding a
     // notice, we can assume the user has seen the notice in question,
     // an no longer need a notification about it. mark reply/mention-
     // notifications tied to this notice and the current profile as read
     if ($this->auth_user) {
         QvitterPlugin::markNotificationAsSeen($this->notice_id, $this->auth_user->id, 'mention');
         QvitterPlugin::markNotificationAsSeen($this->notice_id, $this->auth_user->id, 'reply');
     }
     // favs
     $fave = new Fave();
     $fave->selectAdd();
     $fave->selectAdd('user_id');
     $fave->selectAdd('modified');
     $fave->notice_id = $this->original->id;
     $fave->orderBy('modified');
     if (!is_null($this->cnt)) {
         $fave->limit(0, $this->cnt);
     }
     $fav_ids = $fave->fetchAll('user_id', 'modified');
     // get nickname and profile image
     $fav_ids_with_profile_data = array();
     $i = 0;
     foreach ($fav_ids as $id => $time) {
         $profile = Profile::getKV('id', $id);
         $fav_ids_with_profile_data[$i]['user_id'] = $id;
         $fav_ids_with_profile_data[$i]['nickname'] = $profile->nickname;
         $fav_ids_with_profile_data[$i]['fullname'] = $profile->fullname;
         $fav_ids_with_profile_data[$i]['profileurl'] = $profile->profileurl;
         $fav_ids_with_profile_data[$i]['time'] = strtotime($time);
         $profile = new Profile();
         $profile->id = $id;
         $avatarurl = $profile->avatarUrl(48);
         $fav_ids_with_profile_data[$i]['avatarurl'] = $avatarurl;
         $i++;
     }
     // repeats
     $notice = new Notice();
     $notice->selectAdd();
     // clears it
     $notice->selectAdd('profile_id');
     $notice->selectAdd('created');
     $notice->repeat_of = $this->original->id;
     $notice->verb = ActivityVerb::SHARE;
     $notice->orderBy('created, id');
     // NB: asc!
     if (!is_null($this->cnt)) {
         $notice->limit(0, $this->cnt);
     }
     $repeat_ids = $notice->fetchAll('profile_id', 'created');
     // get nickname and profile image
     $repeat_ids_with_profile_data = array();
     $i = 0;
     foreach ($repeat_ids as $id => $time) {
         $profile = Profile::getKV('id', $id);
         $repeat_ids_with_profile_data[$i]['user_id'] = $id;
         $repeat_ids_with_profile_data[$i]['nickname'] = $profile->nickname;
         $repeat_ids_with_profile_data[$i]['fullname'] = $profile->fullname;
         $repeat_ids_with_profile_data[$i]['profileurl'] = $profile->profileurl;
         $repeat_ids_with_profile_data[$i]['time'] = strtotime($time);
         $profile = new Profile();
         $profile->id = $id;
         $avatarurl = $profile->avatarUrl(48);
         $repeat_ids_with_profile_data[$i]['avatarurl'] = $avatarurl;
         $i++;
     }
     $favs_and_repeats = array('favs' => $fav_ids_with_profile_data, 'repeats' => $repeat_ids_with_profile_data);
     $this->initDocument('json');
     $this->showJsonObjects($favs_and_repeats);
     $this->endDocument('json');
 }
コード例 #23
0
ファイル: apitrends.php プロジェクト: Br3nda/StatusNet
 /**
  * Handle a request
  *
  * @param array $args Arguments from $_REQUEST
  *
  * @return void
  */
 function handle($args)
 {
     parent::handle($args);
     $this->showTrends();
 }
コード例 #24
0
 /**
  * Handle the request
  *
  * Check the format and show the notice
  *
  * @param array $args $_REQUEST data (unused)
  *
  * @return void
  */
 function handle($args)
 {
     parent::handle($args);
     if (!in_array($this->format, array('xml', 'json'))) {
         // TRANS: Client error displayed when trying to handle an unknown API method.
         $this->clientError(_('API method not found.'), $code = 404);
         return;
     }
     $this->showNotice();
 }
コード例 #25
0
 /**
  * Handle the request
  *
  * Just show the notices
  *
  * @param array $args $_REQUEST data (unused)
  *
  * @return void
  */
 function handle($args)
 {
     parent::handle($args);
     $this->showTimeline();
 }
コード例 #26
0
 /**
  * Handle the request
  *
  * Check the format and show the user info
  *
  * @param array $args $_REQUEST data (unused)
  *
  * @return void
  */
 protected function handle()
 {
     parent::handle();
     // favs
     $fave = new Fave();
     $fave->selectAdd();
     $fave->selectAdd('user_id');
     $fave->selectAdd('modified');
     $fave->notice_id = $this->original->id;
     $fave->orderBy('modified');
     if (!is_null($this->cnt)) {
         $fave->limit(0, $this->cnt);
     }
     $fav_ids = $fave->fetchAll('user_id', 'modified');
     // get nickname and profile image
     $fav_ids_with_profile_data = array();
     $i = 0;
     foreach ($fav_ids as $id => $time) {
         $profile = Profile::getKV('id', $id);
         $fav_ids_with_profile_data[$i]['user_id'] = $id;
         $fav_ids_with_profile_data[$i]['nickname'] = $profile->nickname;
         $fav_ids_with_profile_data[$i]['fullname'] = $profile->fullname;
         $fav_ids_with_profile_data[$i]['profileurl'] = $profile->profileurl;
         $fav_ids_with_profile_data[$i]['time'] = strtotime($time);
         $profile = new Profile();
         $profile->id = $id;
         $avatarurl = $profile->avatarUrl(48);
         $fav_ids_with_profile_data[$i]['avatarurl'] = $avatarurl;
         $i++;
     }
     // repeats
     $notice = new Notice();
     $notice->selectAdd();
     // clears it
     $notice->selectAdd('profile_id');
     $notice->selectAdd('created');
     $notice->repeat_of = $this->original->id;
     $notice->orderBy('created, id');
     // NB: asc!
     if (!is_null($this->cnt)) {
         $notice->limit(0, $this->cnt);
     }
     $repeat_ids = $notice->fetchAll('profile_id', 'created');
     // get nickname and profile image
     $repeat_ids_with_profile_data = array();
     $i = 0;
     foreach ($repeat_ids as $id => $time) {
         $profile = Profile::getKV('id', $id);
         $repeat_ids_with_profile_data[$i]['user_id'] = $id;
         $repeat_ids_with_profile_data[$i]['nickname'] = $profile->nickname;
         $repeat_ids_with_profile_data[$i]['fullname'] = $profile->fullname;
         $repeat_ids_with_profile_data[$i]['profileurl'] = $profile->profileurl;
         $repeat_ids_with_profile_data[$i]['time'] = strtotime($time);
         $profile = new Profile();
         $profile->id = $id;
         $avatarurl = $profile->avatarUrl(48);
         $repeat_ids_with_profile_data[$i]['avatarurl'] = $avatarurl;
         $i++;
     }
     $favs_and_repeats = array('favs' => $fav_ids_with_profile_data, 'repeats' => $repeat_ids_with_profile_data);
     $this->initDocument('json');
     $this->showJsonObjects($favs_and_repeats);
     $this->endDocument('json');
 }
コード例 #27
0
 /**
  * Handle the request
  *
  * Check the format and show the notice
  *
  * @param array $args $_REQUEST data (unused)
  *
  * @return void
  */
 function handle($args)
 {
     parent::handle($args);
     if (!in_array($this->format, array('xml', 'json'))) {
         $this->clientError(_('API method not found.'), $code = 404);
         return;
     }
     $this->showNotice();
 }
コード例 #28
0
 /**
  * Handle the request
  *
  * Check the format and show the notice
  *
  * @return void
  */
 protected function handle()
 {
     parent::handle();
     if (!in_array($this->format, array('xml', 'json', 'atom'))) {
         // TRANS: Client error displayed when coming across a non-supported API method.
         $this->clientError(_('API method not found.'), 404);
     }
     switch ($_SERVER['REQUEST_METHOD']) {
         case 'GET':
             $this->showNotice();
             break;
         case 'DELETE':
             $this->deleteNotice();
             break;
         default:
             // TRANS: Client error displayed calling an unsupported HTTP error in API status show.
             $this->clientError(_('HTTP method not supported.'), 405);
     }
 }
コード例 #29
0
 /**
  * Handle a request
  *
  * @param array $args Arguments from $_REQUEST
  *
  * @return void
  */
 function handle($args)
 {
     parent::handle($args);
     common_debug("In apisearchatom handle()");
     $this->showAtom();
 }
コード例 #30
0
 /**
  * Handle the request
  *
  * Check the format and show the user info
  *
  * @param array $args $_REQUEST data (unused)
  *
  * @return void
  */
 function handle($args)
 {
     parent::handle($args);
     switch ($this->format) {
         case 'xml':
             $this->showSingleXmlGroup($this->group);
             break;
         case 'json':
             $this->showSingleJsonGroup($this->group);
             break;
         default:
             $this->clientError(_('API method not found.'), 404, $this->format);
             break;
     }
 }