wrong indent
[friendica-addons.git/.git] / twitter / twitter.php
index 64b8f40..bb2d38a 100644 (file)
@@ -75,6 +75,7 @@ use Friendica\Core\Logger;
 use Friendica\Core\PConfig;
 use Friendica\Core\Protocol;
 use Friendica\Core\Renderer;
+use Friendica\Core\System;
 use Friendica\Core\Worker;
 use Friendica\Database\DBA;
 use Friendica\Model\Contact;
@@ -90,11 +91,6 @@ use Friendica\Util\DateTimeFormat;
 use Friendica\Util\Network;
 use Friendica\Util\Strings;
 
-require_once 'boot.php';
-require_once 'include/dba.php';
-require_once 'include/enotify.php';
-require_once 'include/text.php';
-
 require_once __DIR__ . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php';
 
 define('TWITTER_DEFAULT_POLL_INTERVAL', 5); // given in minutes
@@ -265,7 +261,7 @@ function twitter_settings_post(App $a)
                                info($e->getMessage());
                        }
                        //  reload the Addon Settings page, if we don't do it see Bug #42
-                       $a->internalRedirect('settings/connectors');
+                       System::redirectTo('settings/connectors');
                } else {
                        //  if no PIN is supplied in the POST variables, the user has changed the setting
                        //  to post a tweet for every new __public__ posting to the wall
@@ -804,8 +800,6 @@ function twitter_expire(App $a)
        }
        DBA::close($r);
 
-       require_once "include/items.php";
-
        Logger::log('twitter_expire: expire_start');
 
        $r = q("SELECT * FROM `pconfig` WHERE `cat` = 'twitter' AND `k` = 'import' AND `v` = '1' ORDER BY RAND()");
@@ -935,7 +929,6 @@ function twitter_fetchtimeline(App $a, $uid)
        $has_picture = false;
 
        require_once 'mod/item.php';
-       require_once 'include/items.php';
        require_once 'mod/share.php';
 
        $connection = new TwitterOAuth($ckey, $csecret, $otoken, $osecret);
@@ -1229,9 +1222,11 @@ function twitter_expand_entities(App $a, $body, $item, $picture)
                                        continue;
                                }
 
-                               $expanded_url = Network::finalUrl($url->expanded_url);
+                               $expanded_url = $url->expanded_url;
 
-                               $oembed_data = OEmbed::fetchURL($expanded_url);
+                               $final_url = Network::finalUrl($url->expanded_url);
+
+                               $oembed_data = OEmbed::fetchURL($final_url);
 
                                if (empty($oembed_data) || empty($oembed_data->type)) {
                                        continue;
@@ -1257,7 +1252,7 @@ function twitter_expand_entities(App $a, $body, $item, $picture)
                                } elseif ($oembed_data->type != 'link') {
                                        $body = str_replace($url->url, '[url=' . $expanded_url . ']' . $url->display_url . '[/url]', $body);
                                } else {
-                                       $img_str = Network::fetchUrl($expanded_url, true, $redirects, 4);
+                                       $img_str = Network::fetchUrl($final_url, true, $redirects, 4);
 
                                        $tempfile = tempnam(get_temppath(), 'cache');
                                        file_put_contents($tempfile, $img_str);
@@ -1273,7 +1268,7 @@ function twitter_expand_entities(App $a, $body, $item, $picture)
 
                                        if (substr($mime, 0, 6) == 'image/') {
                                                $type = 'photo';
-                                               $body = str_replace($url->url, '[img]' . $expanded_url . '[/img]', $body);
+                                               $body = str_replace($url->url, '[img]' . $final_url . '[/img]', $body);
                                        } else {
                                                $type = $oembed_data->type;
                                                $footerurl = $expanded_url;
@@ -1663,8 +1658,6 @@ function twitter_fetchhometimeline(App $a, $uid)
                $application_name = $a->getHostName();
        }
 
-       require_once 'include/items.php';
-
        $connection = new TwitterOAuth($ckey, $csecret, $otoken, $osecret);
 
        try {