+ $opts = array('allowed_schemes' => array('http', 'https', 'acct'));
+ if (Validate::uri($this->profile, $opts)) {
+ $bits = parse_url($this->profile);
+ if ($bits['scheme'] == 'acct') {
+ $this->connectWebfinger($bits['path']);
+ } else {
+ $this->connectProfile($this->profile);
+ }
+ } elseif (strpos($this->profile, '@') !== false) {
+ $this->connectWebfinger($this->profile);
+ } else {
+ // TRANS: Client error.
+ $this->clientError(_m('Must provide a remote profile.'));
+ }
+ }
+
+ function connectWebfinger($acct)
+ {
+ $target_profile = $this->targetProfile();
+
+ $disco = new Discovery;
+ $xrd = $disco->lookup($acct);
+
+ $link = $xrd->get('http://ostatus.org/schema/1.0/subscribe');
+ if (!is_null($link)) {
+ // We found a URL - let's redirect!
+ if (!empty($link->template)) {
+ $url = Discovery::applyTemplate($link->template, $target_profile);
+ } else {
+ $url = $link->href;
+ }
+ common_log(LOG_INFO, "Sending remote subscriber $acct to $url");
+ common_redirect($url, 303);
+ }
+ // TRANS: Client error.
+ $this->clientError(_m('Could not confirm remote profile address.'));
+ }