. * * @category API * @package GNUsocial * @author Hannes Mannerheim * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @link http://www.gnu.org/software/social/ */ if (!defined('GNUSOCIAL')) { exit(1); } /** * Ouputs information for a user, specified by ID or screen name. * The user's most recent status will be returned inline. */ class ApiExternalProfileShowAction extends ApiPrivateAuthAction { /** * Take arguments for running * * @param array $args $_REQUEST args * * @return boolean success flag * */ protected function prepare(array $args=array()) { parent::prepare($args); if ($this->format !== 'json') { $this->clientError('This method currently only serves JSON.', 415); } $profileurl = urldecode($this->arg('profileurl')); // TODO: Make this more ... unique! $this->profile = Profile::getKV('profileurl', $profileurl); if (!($this->profile instanceof Profile)) { // TRANS: Client error displayed when requesting profile information for a non-existing profile. $this->clientError(_('Profile not found.'), 404); } return true; } /** * 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'); } /** * Return true if read only. * * MAY override * * @param array $args other arguments * * @return boolean is read only action? */ function isReadOnly($args) { return true; } }