12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- <?php
-
- if (!defined('GNUSOCIAL')) { exit(1); }
- class ApiCheckNicknameAction extends ApiAction
- {
- protected function prepare(array $args=array())
- {
- parent::prepare($args);
- if (common_config('site', 'private')) {
- $this->clientError(_('This site is private.'), 403);
- }
- if ($this->format !== 'json') {
- $this->clientError('This method currently only serves JSON.', 415);
- }
- return true;
- }
- protected function handle()
- {
- parent::handle();
- $nickname = $this->trimmed('nickname');
- try {
- Nickname::normalize($nickname, true);
- $nickname_ok = 1;
- } catch (NicknameException $e) {
- $nickname_ok = 0;
- }
- $this->initDocument('json');
- $this->showJsonObjects($nickname_ok);
- $this->endDocument('json');
- }
- }
|