X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=twitter%2Ftwitter.php;h=aaa378d18098f618693bbe0f8b27eabbe7979586;hb=f5d8604e596f8f50f5e6fa281827c196cbc8148f;hp=f35ff8d3e6d036284f55f560cc89796b2fd3803c;hpb=17df97fccdc680dd3ec2aa7eb808c09460ae1d07;p=friendica-addons.git diff --git a/twitter/twitter.php b/twitter/twitter.php index f35ff8d3..aaa378d1 100644 --- a/twitter/twitter.php +++ b/twitter/twitter.php @@ -6,6 +6,7 @@ * Author: Tobias Diekershoff * Author: Michael Vogel * Maintainer: Hypolite Petovan + * Status: unsupported * * Copyright (c) 2011-2013 Tobias Diekershoff, Michael Vogel, Hypolite Petovan * All rights reserved. @@ -525,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'] = []; } } @@ -1099,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); @@ -1288,10 +1294,10 @@ function twitter_fetchtimeline(int $uid): void $osecret = DI::pConfig()->get($uid, 'twitter', 'oauthsecret'); $lastid = DI::pConfig()->get($uid, 'twitter', 'lastid'); - $application_name = DI::keyValue()->get('twitter_application_name'); + $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); @@ -1693,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]] = [ @@ -2187,10 +2193,10 @@ function twitter_fetchhometimeline(int $uid): void Logger::info('Fetching timeline', ['uid' => $uid]); - $application_name = DI::keyValue()->get('twitter_application_name'); + $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);