. * * @category Plugin * @package GNUsocial * @author Daniel Supernault * @author Diogo Cordeiro * @copyright 2015 Free Software Foundaction, Inc. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @link https://gnu.io/social */ if (!defined('GNUSOCIAL')) { exit(1); } class apActorProfileAction extends ManagedAction { protected $needLogin = false; protected $canPost = true; protected function handle() { $nickname = $this->trimmed('nickname'); try { $user = User::getByNickname($nickname); $profile = $user->getProfile(); $url = $profile->profileurl; } catch (Exception $e) { throw new \Exception('Invalid username'); } $avatar_url = $profile->avatarUrl(AVATAR_PROFILE_SIZE); $res = [ '@context' => [ "https://www.w3.org/ns/activitystreams", [ "@language" => "en" ] ], 'id' => $user->getID(), 'type' => 'Person', 'username' => $user->nickname, 'inbox' => "{$url}/inbox.json", 'outbox' => "{$url}/outbox.json", 'acct' => null, // TODO: Equals `username` for local users, includes `@domain` for remote ones 'display_name' => $profile->fullname, 'followers' => "{$url}/subscribers", 'following' => "{$url}/subscriptions", 'liked' => "{$url}/liked.json", 'liked_count' => Fave::countByProfile ($profile), 'summary' => $profile->bio, 'url' => $url, 'avatar' => [ 'type' => 'Image', 'width' => 96, 'height' => 96, 'url' => $avatar_url ] ]; header('Content-Type: application/json'); echo json_encode($res, isset($_GET["pretty"]) ? JSON_PRETTY_PRINT : null); } }