]> git.mxchange.org Git - friendica-addons.git/commitdiff
Make "HTTPRequest::fetchUrl" dynamic
authornupplaPhil <admin+github@philipp.info>
Wed, 4 Mar 2020 21:20:27 +0000 (22:20 +0100)
committerHypolite Petovan <hypolite@mrpetovan.com>
Tue, 21 Jul 2020 07:30:37 +0000 (03:30 -0400)
curweather/curweather.php
geocoordinates/geocoordinates.php
geonames/geonames.php
jappixmini/jappixmini.php
leistungsschutzrecht/leistungsschutzrecht.php
statusnet/statusnet.php
twitter/twitter.php

index 017a67fa9c9897a9d6c8c5329786ccf91de366a8..7757dba7e42debba013da3f76fe13ebfd91af3fc 100644 (file)
@@ -15,7 +15,6 @@ use Friendica\Core\Hook;
 use Friendica\Core\Renderer;
 use Friendica\Core\Session;
 use Friendica\DI;
-use Friendica\Network\HTTPRequest;
 use Friendica\Util\Proxy as ProxyUtils;
 
 function curweather_install()
@@ -49,7 +48,7 @@ function getWeather($loc, $units = 'metric', $lang = 'en', $appid = '', $cacheti
        }
 
        try {
-               $res = new SimpleXMLElement(HTTPRequest::fetchUrl($url));
+               $res = new SimpleXMLElement(DI::httpRequest()->fetchUrl($url));
        } catch (Exception $e) {
                if (empty($_SESSION['curweather_notice_shown'])) {
                        info(DI::l10n()->t('Error fetching weather data. Error was: '.$e->getMessage()));
index a36cc1149ab5e64b6a24b18c39d3b47f5bc77505..8641d22366dc00e4ff1a327fc160b486ceb78475 100644 (file)
@@ -10,7 +10,6 @@ use Friendica\Core\Hook;
 use Friendica\Core\Logger;
 use Friendica\Core\Renderer;
 use Friendica\DI;
-use Friendica\Network\HTTPRequest;
 use Friendica\Util\Strings;
 
 function geocoordinates_install()
@@ -53,7 +52,7 @@ function geocoordinates_resolve_item(&$item)
                return;
        }
 
-       $s = HTTPRequest::fetchUrl("https://api.opencagedata.com/geocode/v1/json?q=" . $coords[0] . "," . $coords[1] . "&key=" . $key . "&language=" . $language);
+       $s = DI::httpRequest()->fetchUrl("https://api.opencagedata.com/geocode/v1/json?q=" . $coords[0] . "," . $coords[1] . "&key=" . $key . "&language=" . $language);
 
        if (!$s) {
                Logger::log("API could not be queried", Logger::DEBUG);
index 9a01980e7f245ad4b58b7fabaec1869f8c8b0f2a..28d716b5e3683b23abe57638d71634a3490a1c1e 100644 (file)
@@ -11,7 +11,6 @@ use Friendica\Core\Hook;
 use Friendica\Core\Logger;
 use Friendica\Core\Renderer;
 use Friendica\DI;
-use Friendica\Network\HTTPRequest;
 use Friendica\Util\ConfigFileLoader;
 use Friendica\Util\XML;
 
@@ -78,7 +77,7 @@ function geonames_post_hook(App $a, array &$item)
 
        /* OK, we're allowed to do our stuff. */
 
-       $s = HTTPRequest::fetchUrl('http://api.geonames.org/findNearbyPlaceName?lat=' . $coords[0] . '&lng=' . $coords[1] . '&username=' . $geo_account);
+       $s = DI::httpRequest()->fetchUrl('http://api.geonames.org/findNearbyPlaceName?lat=' . $coords[0] . '&lng=' . $coords[1] . '&username=' . $geo_account);
 
        if (!$s) {
                return;
index 908870bb0faf3ced862fbba9c697d9dad6de42ac..52ae56d071cf73eb15318e8ad5ab954b56c01497 100644 (file)
@@ -69,7 +69,6 @@ use Friendica\Core\Protocol;
 use Friendica\Database\DBA;
 use Friendica\DI;
 use Friendica\Model\User;
-use Friendica\Network\HTTPRequest;
 
 function jappixmini_install()
 {
@@ -660,7 +659,7 @@ function jappixmini_cron(App $a, $d)
 
                        try {
                                // send request
-                               $answer_json = HTTPRequest::fetchUrl($url);
+                               $answer_json = DI::httpRequest()->fetchUrl($url);
 
                                // parse answer
                                $answer = json_decode($answer_json);
index 142661a69989adfdf65b644fec7d477d1f423568..9bd1a68d0064191261b4b88e5375c733ba2cd2ef 100644 (file)
@@ -9,7 +9,6 @@
 use Friendica\Core\Hook;
 use Friendica\Core\Logger;
 use Friendica\DI;
-use Friendica\Network\HTTPRequest;
 
 function leistungsschutzrecht_install() {
        Hook::register('cron', 'addon/leistungsschutzrecht/leistungsschutzrecht.php', 'leistungsschutzrecht_cron');
@@ -80,7 +79,7 @@ function leistungsschutzrecht_fetchsites()
 {
        // This list works - but question is how current it is
        $url = "http://leistungsschutzrecht-stoppen.d-64.org/blacklist.txt";
-       $sitelist = HTTPRequest::fetchUrl($url);
+       $sitelist = DI::httpRequest()->fetchUrl($url);
        $siteurls = explode(',', $sitelist);
 
        $whitelist = ['tagesschau.de', 'heute.de', 'wdr.de'];
index 49ba2e4524878a4591538b1fc547d04c8ae94483..a204f3e31a88a8c4eb596d38014443bb7bc02a1e 100644 (file)
@@ -55,7 +55,6 @@ use Friendica\Model\Item;
 use Friendica\Model\ItemContent;
 use Friendica\Model\Photo;
 use Friendica\Model\User;
-use Friendica\Network\HTTPRequest;
 use Friendica\Protocol\Activity;
 use Friendica\Util\DateTimeFormat;
 use Friendica\Util\Network;
@@ -156,7 +155,7 @@ function statusnet_settings_post(App $a, $post)
                        foreach ($globalsn as $asn) {
                                if ($asn['apiurl'] == $_POST['statusnet-preconf-apiurl']) {
                                        $apibase = $asn['apiurl'];
-                                       $c = HTTPRequest::fetchUrl($apibase . 'statusnet/version.xml');
+                                       $c = DI::httpRequest()->fetchUrl($apibase . 'statusnet/version.xml');
                                        if (strlen($c) > 0) {
                                                DI::pConfig()->set(local_user(), 'statusnet', 'consumerkey', $asn['consumerkey']);
                                                DI::pConfig()->set(local_user(), 'statusnet', 'consumersecret', $asn['consumersecret']);
@@ -174,7 +173,7 @@ function statusnet_settings_post(App $a, $post)
                                //  we'll check the API Version for that, if we don't get one we'll try to fix the path but will
                                //  resign quickly after this one try to fix the path ;-)
                                $apibase = $_POST['statusnet-baseapi'];
-                               $c = HTTPRequest::fetchUrl($apibase . 'statusnet/version.xml');
+                               $c = DI::httpRequest()->fetchUrl($apibase . 'statusnet/version.xml');
                                if (strlen($c) > 0) {
                                        //  ok the API path is correct, let's save the settings
                                        DI::pConfig()->set(local_user(), 'statusnet', 'consumerkey', $_POST['statusnet-consumerkey']);
@@ -184,7 +183,7 @@ function statusnet_settings_post(App $a, $post)
                                } else {
                                        //  the API path is not correct, maybe missing trailing / ?
                                        $apibase = $apibase . '/';
-                                       $c = HTTPRequest::fetchUrl($apibase . 'statusnet/version.xml');
+                                       $c = DI::httpRequest()->fetchUrl($apibase . 'statusnet/version.xml');
                                        if (strlen($c) > 0) {
                                                //  ok the API path is now correct, let's save the settings
                                                DI::pConfig()->set(local_user(), 'statusnet', 'consumerkey', $_POST['statusnet-consumerkey']);
@@ -614,7 +613,7 @@ function statusnet_post_hook(App $a, &$b)
                }
 
                if ($image != "") {
-                       $img_str = HTTPRequest::fetchUrl($image);
+                       $img_str = DI::httpRequest()->fetchUrl($image);
                        $tempfile = tempnam(get_temppath(), "cache");
                        file_put_contents($tempfile, $img_str);
                        $postdata = ["status" => $msg, "media[]" => $tempfile];
@@ -1475,7 +1474,7 @@ function statusnet_convertmsg(App $a, $body)
                        } elseif ($oembed_data->type != "link") {
                                $body = str_replace($search, "[url=" . $expanded_url . "]" . $expanded_url . "[/url]", $body);
                        } else {
-                               $img_str = HTTPRequest::fetchUrl($expanded_url, true, 4);
+                               $img_str = DI::httpRequest()->fetchUrl($expanded_url, true, 4);
 
                                $tempfile = tempnam(get_temppath(), "cache");
                                file_put_contents($tempfile, $img_str);
index 85647dea667e294af0505d4cde1e93a5bf9947b0..f93b12b44da334a67eda30de49329ef96da9af7d 100644 (file)
@@ -85,7 +85,6 @@ use Friendica\Model\ItemContent;
 use Friendica\Model\ItemURI;
 use Friendica\Model\Tag;
 use Friendica\Model\User;
-use Friendica\Network\HTTPRequest;
 use Friendica\Protocol\Activity;
 use Friendica\Util\ConfigFileLoader;
 use Friendica\Util\DateTimeFormat;
@@ -675,7 +674,7 @@ function twitter_post_hook(App $a, array &$b)
                                                continue;
                                        }
 
-                                       $img_str = HTTPRequest::fetchUrl($image['url']);
+                                       $img_str = DI::httpRequest()->fetchUrl($image['url']);
 
                                        $tempfile = tempnam(get_temppath(), 'cache');
                                        file_put_contents($tempfile, $img_str);
@@ -1319,7 +1318,7 @@ function twitter_expand_entities($body, stdClass $status, $picture)
                        } elseif ($oembed_data->type != 'link') {
                                $replace = '[url=' . $expanded_url . ']' . $url->display_url . '[/url]';
                        } else {
-                               $img_str = HTTPRequest::fetchUrl($final_url, true, 4);
+                               $img_str = DI::httpRequest()->fetchUrl($final_url, true, 4);
 
                                $tempfile = tempnam(get_temppath(), 'cache');
                                file_put_contents($tempfile, $img_str);