]> git.mxchange.org Git - friendica-addons.git/blobdiff - twitter/twitter.php
[twitter] Return null in the probe_detect hook result key on unsuccessful probe
[friendica-addons.git] / twitter / twitter.php
index 8c396dcfce88ffec1a229e71dacc299e94eaf135..aaa378d18098f618693bbe0f8b27eabbe7979586 100644 (file)
@@ -526,7 +526,12 @@ function twitter_probe_detect(array &$hookData)
        $user = twitter_fetchuser($nick);
 
        if ($user) {
-               $hookData['result'] = twitter_user_to_contact($user);
+               $hookData['result'] = twitter_user_to_contact($user) ?: null;
+       }
+
+       // Authoritative probe should set the result even if the probe was unsuccessful
+       if ($hookData['network'] == Protocol::TWITTER && empty($hookData['result'])) {
+               $hookData['result'] = [];
        }
 }
 
@@ -1100,7 +1105,7 @@ function twitter_prepare_body(array &$b)
        if ($b['preview']) {
                $max_char = 280;
                $item = $b['item'];
-               $item['plink'] = DI::baseUrl()->get() . '/display/' . $item['guid'];
+               $item['plink'] = DI::baseUrl() . '/display/' . $item['guid'];
 
                $condition = ['uri' => $item['thr-parent'], 'uid' => DI::userSession()->getLocalUserId()];
                $orig_post = Post::selectFirst(['author-link'], $condition);
@@ -1292,7 +1297,7 @@ function twitter_fetchtimeline(int $uid): void
        $application_name = DI::keyValue()->get('twitter_application_name') ?? '';
 
        if ($application_name == '') {
-               $application_name = DI::baseUrl()->getHostname();
+               $application_name = DI::baseUrl()->getHost();
        }
 
        $connection = new TwitterOAuth($ckey, $csecret, $otoken, $osecret);
@@ -1694,7 +1699,7 @@ function twitter_expand_entities($body, stdClass $status)
        $replacementList = [];
 
        foreach ($status->entities->hashtags AS $hashtag) {
-               $replace = '#[url=' . DI::baseUrl()->get() . '/search?tag=' . $hashtag->text . ']' . $hashtag->text . '[/url]';
+               $replace = '#[url=' . DI::baseUrl() . '/search?tag=' . $hashtag->text . ']' . $hashtag->text . '[/url]';
                $taglist['#' . $hashtag->text] = ['#', $hashtag->text, ''];
 
                $replacementList[$hashtag->indices[0]] = [
@@ -2191,7 +2196,7 @@ function twitter_fetchhometimeline(int $uid): void
        $application_name = DI::keyValue()->get('twitter_application_name') ?? '';
 
        if ($application_name == '') {
-               $application_name = DI::baseUrl()->getHostname();
+               $application_name = DI::baseUrl()->getHost();
        }
 
        $connection = new TwitterOAuth($ckey, $csecret, $otoken, $osecret);