123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119 |
- <?php
- if (!defined('GNUSOCIAL')) { exit(1); }
- class ApiFriendshipsExistsAction extends ApiPrivateAuthAction
- {
- var $profile_a = null;
- var $profile_b = null;
-
- protected function prepare(array $args=array())
- {
- parent::prepare($args);
- $this->profile_a = $this->getTargetProfile($this->trimmed('user_a'));
- $this->profile_b = $this->getTargetProfile($this->trimmed('user_b'));
- return true;
- }
-
- 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;
- }
- }
-
- function isReadOnly($args)
- {
- return true;
- }
- }
|