From 9640142a720dfc7683e7bbf60d6f4f8799b918e9 Mon Sep 17 00:00:00 2001 From: nupplaPhil Date: Wed, 4 Mar 2020 22:07:04 +0100 Subject: [PATCH 1/9] Move post/curl/fetchUrl/fetchUrlFull to own class "Network\HTTPRequest" --- blogger/blogger.php | 4 ++-- curweather/curweather.php | 4 ++-- discourse/discourse.php | 13 +++++++------ dwpost/dwpost.php | 4 ++-- geocoordinates/geocoordinates.php | 5 +++-- geonames/geonames.php | 4 ++-- ijpost/ijpost.php | 4 ++-- jappixmini/jappixmini.php | 4 ++-- leistungsschutzrecht/leistungsschutzrecht.php | 5 +++-- libertree/libertree.php | 4 ++-- ljpost/ljpost.php | 4 ++-- mailstream/mailstream.php | 6 +++--- mastodoncustomemojis/mastodoncustomemojis.php | 4 ++-- openstreetmap/openstreetmap.php | 6 +++--- pumpio/pumpio.php | 4 ++-- statusnet/statusnet.php | 11 ++++++----- twitter/twitter.php | 5 +++-- wppost/wppost.php | 4 ++-- 18 files changed, 50 insertions(+), 45 deletions(-) diff --git a/blogger/blogger.php b/blogger/blogger.php index e0b5f5352..f17f1b1e9 100644 --- a/blogger/blogger.php +++ b/blogger/blogger.php @@ -11,7 +11,7 @@ use Friendica\Content\Text\BBCode; use Friendica\Core\Hook; use Friendica\Core\Logger; use Friendica\DI; -use Friendica\Util\Network; +use Friendica\Network\HTTPRequest; use Friendica\Util\XML; function blogger_install() @@ -225,7 +225,7 @@ EOT; Logger::log('blogger: data: ' . $xml, Logger::DATA); if ($bl_blog !== 'test') { - $x = Network::post($bl_blog, $xml)->getBody(); + $x = HTTPRequest::post($bl_blog, $xml)->getBody(); } Logger::log('posted to blogger: ' . (($x) ? $x : ''), Logger::DEBUG); diff --git a/curweather/curweather.php b/curweather/curweather.php index e4b6119f9..017a67fa9 100644 --- a/curweather/curweather.php +++ b/curweather/curweather.php @@ -15,7 +15,7 @@ use Friendica\Core\Hook; use Friendica\Core\Renderer; use Friendica\Core\Session; use Friendica\DI; -use Friendica\Util\Network; +use Friendica\Network\HTTPRequest; use Friendica\Util\Proxy as ProxyUtils; function curweather_install() @@ -49,7 +49,7 @@ function getWeather($loc, $units = 'metric', $lang = 'en', $appid = '', $cacheti } try { - $res = new SimpleXMLElement(Network::fetchUrl($url)); + $res = new SimpleXMLElement(HTTPRequest::fetchUrl($url)); } catch (Exception $e) { if (empty($_SESSION['curweather_notice_shown'])) { info(DI::l10n()->t('Error fetching weather data. Error was: '.$e->getMessage())); diff --git a/discourse/discourse.php b/discourse/discourse.php index f42cb04c1..06b866776 100644 --- a/discourse/discourse.php +++ b/discourse/discourse.php @@ -7,18 +7,19 @@ * Author: Michael Vogel * */ + use Friendica\App; +use Friendica\Content\Text\Markdown; use Friendica\Core\Hook; use Friendica\Core\Logger; -use Friendica\Core\Renderer; use Friendica\Core\Protocol; +use Friendica\Core\Renderer; use Friendica\Database\DBA; use Friendica\DI; use Friendica\Model\Contact; -use Friendica\Content\Text\Markdown; -use Friendica\Util\Network; +use Friendica\Network\HTTPRequest; +use Friendica\Util\DateTimeFormat; use Friendica\Util\Strings; -Use Friendica\Util\DateTimeFormat; /* Todo: * - Obtaining API tokens to be able to read non public posts as well @@ -114,7 +115,7 @@ function discourse_email_getmessage(App $a, &$message) function discourse_fetch_post($host, $topic, $pid) { $url = $host . '/t/' . $topic . '/' . $pid . '.json'; - $curlResult = Network::curl($url); + $curlResult = HTTPRequest::curl($url); if (!$curlResult->isSuccess()) { Logger::info('No success', ['url' => $url]); return false; @@ -151,7 +152,7 @@ function discourse_fetch_post_from_api(&$message, $post, $host) { $hostaddr = 'https://' . $host; $url = $hostaddr . '/posts/' . $post . '.json'; - $curlResult = Network::curl($url); + $curlResult = HTTPRequest::curl($url); if (!$curlResult->isSuccess()) { return false; } diff --git a/dwpost/dwpost.php b/dwpost/dwpost.php index 3d4b42ad8..bb45dd14e 100644 --- a/dwpost/dwpost.php +++ b/dwpost/dwpost.php @@ -15,8 +15,8 @@ use Friendica\Core\Logger; use Friendica\Database\DBA; use Friendica\DI; use Friendica\Model\Tag; +use Friendica\Network\HTTPRequest; use Friendica\Util\DateTimeFormat; -use Friendica\Util\Network; use Friendica\Util\XML; function dwpost_install() @@ -231,7 +231,7 @@ EOT; Logger::log('dwpost: data: ' . $xml, Logger::DATA); if ($dw_blog !== 'test') { - $x = Network::post($dw_blog, $xml, ["Content-Type: text/xml"])->getBody(); + $x = HTTPRequest::post($dw_blog, $xml, ["Content-Type: text/xml"])->getBody(); } Logger::log('posted to dreamwidth: ' . ($x) ? $x : '', Logger::DEBUG); diff --git a/geocoordinates/geocoordinates.php b/geocoordinates/geocoordinates.php index 7a7a6d9ad..a36cc1149 100644 --- a/geocoordinates/geocoordinates.php +++ b/geocoordinates/geocoordinates.php @@ -5,11 +5,12 @@ * Version: 0.1 * Author: Michael Vogel */ + use Friendica\Core\Hook; use Friendica\Core\Logger; use Friendica\Core\Renderer; use Friendica\DI; -use Friendica\Util\Network; +use Friendica\Network\HTTPRequest; use Friendica\Util\Strings; function geocoordinates_install() @@ -52,7 +53,7 @@ function geocoordinates_resolve_item(&$item) return; } - $s = Network::fetchUrl("https://api.opencagedata.com/geocode/v1/json?q=".$coords[0].",".$coords[1]."&key=".$key."&language=".$language); + $s = 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); diff --git a/geonames/geonames.php b/geonames/geonames.php index e6962d764..9a01980e7 100644 --- a/geonames/geonames.php +++ b/geonames/geonames.php @@ -11,8 +11,8 @@ 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\Network; use Friendica\Util\XML; function geonames_install() @@ -78,7 +78,7 @@ function geonames_post_hook(App $a, array &$item) /* OK, we're allowed to do our stuff. */ - $s = Network::fetchUrl('http://api.geonames.org/findNearbyPlaceName?lat=' . $coords[0] . '&lng=' . $coords[1] . '&username=' . $geo_account); + $s = HTTPRequest::fetchUrl('http://api.geonames.org/findNearbyPlaceName?lat=' . $coords[0] . '&lng=' . $coords[1] . '&username=' . $geo_account); if (!$s) { return; diff --git a/ijpost/ijpost.php b/ijpost/ijpost.php index 00479e3e0..1c6b9509f 100644 --- a/ijpost/ijpost.php +++ b/ijpost/ijpost.php @@ -13,8 +13,8 @@ use Friendica\Core\Hook; use Friendica\Core\Logger; use Friendica\DI; use Friendica\Model\Tag; +use Friendica\Network\HTTPRequest; use Friendica\Util\DateTimeFormat; -use Friendica\Util\Network; use Friendica\Util\XML; function ijpost_install() @@ -229,7 +229,7 @@ EOT; Logger::log('ijpost: data: ' . $xml, Logger::DATA); if ($ij_blog !== 'test') { - $x = Network::post($ij_blog, $xml, ["Content-Type: text/xml"])->getBody(); + $x = HTTPRequest::post($ij_blog, $xml, ["Content-Type: text/xml"])->getBody(); } Logger::log('posted to insanejournal: ' . $x ? $x : '', Logger::DEBUG); } diff --git a/jappixmini/jappixmini.php b/jappixmini/jappixmini.php index ad4d49014..908870bb0 100644 --- a/jappixmini/jappixmini.php +++ b/jappixmini/jappixmini.php @@ -69,7 +69,7 @@ use Friendica\Core\Protocol; use Friendica\Database\DBA; use Friendica\DI; use Friendica\Model\User; -use Friendica\Util\Network; +use Friendica\Network\HTTPRequest; function jappixmini_install() { @@ -660,7 +660,7 @@ function jappixmini_cron(App $a, $d) try { // send request - $answer_json = Network::fetchUrl($url); + $answer_json = HTTPRequest::fetchUrl($url); // parse answer $answer = json_decode($answer_json); diff --git a/leistungsschutzrecht/leistungsschutzrecht.php b/leistungsschutzrecht/leistungsschutzrecht.php index 8bb6f526b..142661a69 100644 --- a/leistungsschutzrecht/leistungsschutzrecht.php +++ b/leistungsschutzrecht/leistungsschutzrecht.php @@ -5,10 +5,11 @@ * Version: 0.1 * Author: Michael Vogel */ + use Friendica\Core\Hook; use Friendica\Core\Logger; use Friendica\DI; -use Friendica\Util\Network; +use Friendica\Network\HTTPRequest; function leistungsschutzrecht_install() { Hook::register('cron', 'addon/leistungsschutzrecht/leistungsschutzrecht.php', 'leistungsschutzrecht_cron'); @@ -79,7 +80,7 @@ function leistungsschutzrecht_fetchsites() { // This list works - but question is how current it is $url = "http://leistungsschutzrecht-stoppen.d-64.org/blacklist.txt"; - $sitelist = Network::fetchUrl($url); + $sitelist = HTTPRequest::fetchUrl($url); $siteurls = explode(',', $sitelist); $whitelist = ['tagesschau.de', 'heute.de', 'wdr.de']; diff --git a/libertree/libertree.php b/libertree/libertree.php index 01a9d9420..23442da20 100644 --- a/libertree/libertree.php +++ b/libertree/libertree.php @@ -12,7 +12,7 @@ use Friendica\Core\Hook; use Friendica\Core\Logger; use Friendica\Database\DBA; use Friendica\DI; -use Friendica\Util\Network; +use Friendica\Network\HTTPRequest; function libertree_install() { @@ -243,7 +243,7 @@ function libertree_send(&$a,&$b) { // 'token' => $ltree_api_token ]; - $result = Network::post($ltree_blog, $params)->getBody(); + $result = HTTPRequest::post($ltree_blog, $params)->getBody(); Logger::log('libertree: ' . $result); } } diff --git a/ljpost/ljpost.php b/ljpost/ljpost.php index 5120612d0..4420775a8 100644 --- a/ljpost/ljpost.php +++ b/ljpost/ljpost.php @@ -13,8 +13,8 @@ use Friendica\Core\Hook; use Friendica\Core\Logger; use Friendica\DI; use Friendica\Model\Tag; +use Friendica\Network\HTTPRequest; use Friendica\Util\DateTimeFormat; -use Friendica\Util\Network; use Friendica\Util\XML; function ljpost_install() { @@ -241,7 +241,7 @@ EOT; Logger::log('ljpost: data: ' . $xml, Logger::DATA); if ($lj_blog !== 'test') { - $x = Network::post($lj_blog, $xml, ["Content-Type: text/xml"])->getBody(); + $x = HTTPRequest::post($lj_blog, $xml, ["Content-Type: text/xml"])->getBody(); } Logger::log('posted to livejournal: ' . ($x) ? $x : '', Logger::DEBUG); } diff --git a/mailstream/mailstream.php b/mailstream/mailstream.php index 89e6cc014..dbc9c4f08 100644 --- a/mailstream/mailstream.php +++ b/mailstream/mailstream.php @@ -12,9 +12,9 @@ use Friendica\Core\Logger; use Friendica\Core\Renderer; use Friendica\Database\DBA; use Friendica\DI; -use Friendica\Protocol\Activity; -use Friendica\Util\Network; use Friendica\Model\Item; +use Friendica\Network\HTTPRequest; +use Friendica\Protocol\Activity; function mailstream_install() { Hook::register('addon_settings', 'addon/mailstream/mailstream.php', 'mailstream_addon_settings'); @@ -169,7 +169,7 @@ function mailstream_do_images($a, &$item, &$attachments) { continue; } $cookiejar = tempnam(get_temppath(), 'cookiejar-mailstream-'); - $curlResult = Network::fetchUrlFull($url, true, 0, '', $cookiejar); + $curlResult = HTTPRequest::fetchUrlFull($url, true, 0, '', $cookiejar); $attachments[$url] = [ 'data' => $curlResult->getBody(), 'guid' => hash("crc32", $url), diff --git a/mastodoncustomemojis/mastodoncustomemojis.php b/mastodoncustomemojis/mastodoncustomemojis.php index a6c95d340..a0c06b97c 100644 --- a/mastodoncustomemojis/mastodoncustomemojis.php +++ b/mastodoncustomemojis/mastodoncustomemojis.php @@ -15,7 +15,7 @@ use Friendica\Core\Cache\Duration; use Friendica\Core\Hook; use Friendica\Core\Protocol; use Friendica\DI; -use Friendica\Util\Network; +use Friendica\Network\HTTPRequest; use Friendica\Util\Proxy as ProxyUtils; function mastodoncustomemojis_install() @@ -90,7 +90,7 @@ function mastodoncustomemojis_fetch_custom_emojis_for_url($api_base_url) $api_url = $api_base_url . '/api/v1/custom_emojis'; - $fetchResult = Network::fetchUrlFull($api_url); + $fetchResult = HTTPRequest::fetchUrlFull($api_url); if ($fetchResult->isSuccess()) { $emojis_array = json_decode($fetchResult->getBody(), true); diff --git a/openstreetmap/openstreetmap.php b/openstreetmap/openstreetmap.php index 5df1c7d7d..370eb9104 100644 --- a/openstreetmap/openstreetmap.php +++ b/openstreetmap/openstreetmap.php @@ -9,13 +9,13 @@ * */ -use Friendica\DI; use Friendica\Core\Cache\Duration; 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\Network; use Friendica\Util\Strings; const OSM_TMS = 'https://www.openstreetmap.org'; @@ -132,7 +132,7 @@ function openstreetmap_get_coordinates($a, &$b) $j = DI::cache()->get($cachekey); if (is_null($j)) { - $curlResult = Network::curl($nomserver . $args); + $curlResult = HTTPRequest::curl($nomserver . $args); if ($curlResult->isSuccess()) { $j = json_decode($curlResult->getBody(), true); DI::cache()->set($cachekey, $j, Duration::MONTH); diff --git a/pumpio/pumpio.php b/pumpio/pumpio.php index 567f64c8d..c58667b2e 100644 --- a/pumpio/pumpio.php +++ b/pumpio/pumpio.php @@ -19,11 +19,11 @@ use Friendica\Model\Contact; use Friendica\Model\Group; use Friendica\Model\Item; use Friendica\Model\User; +use Friendica\Network\HTTPRequest; use Friendica\Protocol\Activity; use Friendica\Protocol\ActivityNamespace; use Friendica\Util\ConfigFileLoader; use Friendica\Util\DateTimeFormat; -use Friendica\Util\Network; use Friendica\Util\Strings; use Friendica\Util\XML; @@ -1605,7 +1605,7 @@ function pumpio_fetchallcomments(App $a, $uid, $id) function pumpio_reachable($url) { - return Network::curl($url, false, ['timeout' => 10])->isSuccess(); + return HTTPRequest::curl($url, false, ['timeout' => 10])->isSuccess(); } /* diff --git a/statusnet/statusnet.php b/statusnet/statusnet.php index 0fd1fd79f..49ba2e452 100644 --- a/statusnet/statusnet.php +++ b/statusnet/statusnet.php @@ -55,6 +55,7 @@ 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; @@ -155,7 +156,7 @@ function statusnet_settings_post(App $a, $post) foreach ($globalsn as $asn) { if ($asn['apiurl'] == $_POST['statusnet-preconf-apiurl']) { $apibase = $asn['apiurl']; - $c = Network::fetchUrl($apibase . 'statusnet/version.xml'); + $c = 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']); @@ -173,7 +174,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 = Network::fetchUrl($apibase . 'statusnet/version.xml'); + $c = 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']); @@ -183,7 +184,7 @@ function statusnet_settings_post(App $a, $post) } else { // the API path is not correct, maybe missing trailing / ? $apibase = $apibase . '/'; - $c = Network::fetchUrl($apibase . 'statusnet/version.xml'); + $c = 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']); @@ -613,7 +614,7 @@ function statusnet_post_hook(App $a, &$b) } if ($image != "") { - $img_str = Network::fetchUrl($image); + $img_str = HTTPRequest::fetchUrl($image); $tempfile = tempnam(get_temppath(), "cache"); file_put_contents($tempfile, $img_str); $postdata = ["status" => $msg, "media[]" => $tempfile]; @@ -1474,7 +1475,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 = Network::fetchUrl($expanded_url, true, 4); + $img_str = HTTPRequest::fetchUrl($expanded_url, true, 4); $tempfile = tempnam(get_temppath(), "cache"); file_put_contents($tempfile, $img_str); diff --git a/twitter/twitter.php b/twitter/twitter.php index 948bb6be6..85647dea6 100644 --- a/twitter/twitter.php +++ b/twitter/twitter.php @@ -85,6 +85,7 @@ 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; @@ -674,7 +675,7 @@ function twitter_post_hook(App $a, array &$b) continue; } - $img_str = Network::fetchUrl($image['url']); + $img_str = HTTPRequest::fetchUrl($image['url']); $tempfile = tempnam(get_temppath(), 'cache'); file_put_contents($tempfile, $img_str); @@ -1318,7 +1319,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 = Network::fetchUrl($final_url, true, 4); + $img_str = HTTPRequest::fetchUrl($final_url, true, 4); $tempfile = tempnam(get_temppath(), 'cache'); file_put_contents($tempfile, $img_str); diff --git a/wppost/wppost.php b/wppost/wppost.php index 4d32c7904..0d860ef57 100644 --- a/wppost/wppost.php +++ b/wppost/wppost.php @@ -12,7 +12,7 @@ use Friendica\Core\Hook; use Friendica\Core\Logger; use Friendica\Database\DBA; use Friendica\DI; -use Friendica\Util\Network; +use Friendica\Network\HTTPRequest; use Friendica\Util\Strings; use Friendica\Util\XML; @@ -338,7 +338,7 @@ EOT; Logger::log('wppost: data: ' . $xml, Logger::DATA); if ($wp_blog !== 'test') { - $x = Network::post($wp_blog, $xml)->getBody(); + $x = HTTPRequest::post($wp_blog, $xml)->getBody(); } Logger::log('posted to wordpress: ' . (($x) ? $x : ''), Logger::DEBUG); } From 688c556739ce4b55fac78c574a0b16154411049c Mon Sep 17 00:00:00 2001 From: nupplaPhil Date: Wed, 4 Mar 2020 22:15:45 +0100 Subject: [PATCH 2/9] Make "HTTPRequest::curl" dynamic --- discourse/discourse.php | 5 ++--- openstreetmap/openstreetmap.php | 3 +-- pumpio/pumpio.php | 3 +-- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/discourse/discourse.php b/discourse/discourse.php index 06b866776..5e64c173e 100644 --- a/discourse/discourse.php +++ b/discourse/discourse.php @@ -17,7 +17,6 @@ use Friendica\Core\Renderer; use Friendica\Database\DBA; use Friendica\DI; use Friendica\Model\Contact; -use Friendica\Network\HTTPRequest; use Friendica\Util\DateTimeFormat; use Friendica\Util\Strings; @@ -115,7 +114,7 @@ function discourse_email_getmessage(App $a, &$message) function discourse_fetch_post($host, $topic, $pid) { $url = $host . '/t/' . $topic . '/' . $pid . '.json'; - $curlResult = HTTPRequest::curl($url); + $curlResult = DI::httpRequest()->curl($url); if (!$curlResult->isSuccess()) { Logger::info('No success', ['url' => $url]); return false; @@ -152,7 +151,7 @@ function discourse_fetch_post_from_api(&$message, $post, $host) { $hostaddr = 'https://' . $host; $url = $hostaddr . '/posts/' . $post . '.json'; - $curlResult = HTTPRequest::curl($url); + $curlResult = DI::httpRequest()->curl($url); if (!$curlResult->isSuccess()) { return false; } diff --git a/openstreetmap/openstreetmap.php b/openstreetmap/openstreetmap.php index 370eb9104..ede71ccd4 100644 --- a/openstreetmap/openstreetmap.php +++ b/openstreetmap/openstreetmap.php @@ -14,7 +14,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\Strings; @@ -132,7 +131,7 @@ function openstreetmap_get_coordinates($a, &$b) $j = DI::cache()->get($cachekey); if (is_null($j)) { - $curlResult = HTTPRequest::curl($nomserver . $args); + $curlResult = DI::httpRequest()->curl($nomserver . $args); if ($curlResult->isSuccess()) { $j = json_decode($curlResult->getBody(), true); DI::cache()->set($cachekey, $j, Duration::MONTH); diff --git a/pumpio/pumpio.php b/pumpio/pumpio.php index c58667b2e..d85902841 100644 --- a/pumpio/pumpio.php +++ b/pumpio/pumpio.php @@ -19,7 +19,6 @@ use Friendica\Model\Contact; use Friendica\Model\Group; use Friendica\Model\Item; use Friendica\Model\User; -use Friendica\Network\HTTPRequest; use Friendica\Protocol\Activity; use Friendica\Protocol\ActivityNamespace; use Friendica\Util\ConfigFileLoader; @@ -1605,7 +1604,7 @@ function pumpio_fetchallcomments(App $a, $uid, $id) function pumpio_reachable($url) { - return HTTPRequest::curl($url, false, ['timeout' => 10])->isSuccess(); + return DI::httpRequest()->curl($url, false, ['timeout' => 10])->isSuccess(); } /* From 20056dc79567248394381a16cc8dd886054d4fc0 Mon Sep 17 00:00:00 2001 From: nupplaPhil Date: Wed, 4 Mar 2020 22:18:27 +0100 Subject: [PATCH 3/9] Make "HTTPRequest::post" dynamic --- blogger/blogger.php | 3 +-- dwpost/dwpost.php | 3 +-- ijpost/ijpost.php | 3 +-- libertree/libertree.php | 3 +-- ljpost/ljpost.php | 3 +-- wppost/wppost.php | 3 +-- 6 files changed, 6 insertions(+), 12 deletions(-) diff --git a/blogger/blogger.php b/blogger/blogger.php index f17f1b1e9..0d201305f 100644 --- a/blogger/blogger.php +++ b/blogger/blogger.php @@ -11,7 +11,6 @@ use Friendica\Content\Text\BBCode; use Friendica\Core\Hook; use Friendica\Core\Logger; use Friendica\DI; -use Friendica\Network\HTTPRequest; use Friendica\Util\XML; function blogger_install() @@ -225,7 +224,7 @@ EOT; Logger::log('blogger: data: ' . $xml, Logger::DATA); if ($bl_blog !== 'test') { - $x = HTTPRequest::post($bl_blog, $xml)->getBody(); + $x = DI::httpRequest()->post($bl_blog, $xml)->getBody(); } Logger::log('posted to blogger: ' . (($x) ? $x : ''), Logger::DEBUG); diff --git a/dwpost/dwpost.php b/dwpost/dwpost.php index bb45dd14e..9a973b672 100644 --- a/dwpost/dwpost.php +++ b/dwpost/dwpost.php @@ -15,7 +15,6 @@ use Friendica\Core\Logger; use Friendica\Database\DBA; use Friendica\DI; use Friendica\Model\Tag; -use Friendica\Network\HTTPRequest; use Friendica\Util\DateTimeFormat; use Friendica\Util\XML; @@ -231,7 +230,7 @@ EOT; Logger::log('dwpost: data: ' . $xml, Logger::DATA); if ($dw_blog !== 'test') { - $x = HTTPRequest::post($dw_blog, $xml, ["Content-Type: text/xml"])->getBody(); + $x = DI::httpRequest()->post($dw_blog, $xml, ["Content-Type: text/xml"])->getBody(); } Logger::log('posted to dreamwidth: ' . ($x) ? $x : '', Logger::DEBUG); diff --git a/ijpost/ijpost.php b/ijpost/ijpost.php index 1c6b9509f..0619c288a 100644 --- a/ijpost/ijpost.php +++ b/ijpost/ijpost.php @@ -13,7 +13,6 @@ use Friendica\Core\Hook; use Friendica\Core\Logger; use Friendica\DI; use Friendica\Model\Tag; -use Friendica\Network\HTTPRequest; use Friendica\Util\DateTimeFormat; use Friendica\Util\XML; @@ -229,7 +228,7 @@ EOT; Logger::log('ijpost: data: ' . $xml, Logger::DATA); if ($ij_blog !== 'test') { - $x = HTTPRequest::post($ij_blog, $xml, ["Content-Type: text/xml"])->getBody(); + $x = DI::httpRequest()->post($ij_blog, $xml, ["Content-Type: text/xml"])->getBody(); } Logger::log('posted to insanejournal: ' . $x ? $x : '', Logger::DEBUG); } diff --git a/libertree/libertree.php b/libertree/libertree.php index 23442da20..dfa492235 100644 --- a/libertree/libertree.php +++ b/libertree/libertree.php @@ -12,7 +12,6 @@ use Friendica\Core\Hook; use Friendica\Core\Logger; use Friendica\Database\DBA; use Friendica\DI; -use Friendica\Network\HTTPRequest; function libertree_install() { @@ -243,7 +242,7 @@ function libertree_send(&$a,&$b) { // 'token' => $ltree_api_token ]; - $result = HTTPRequest::post($ltree_blog, $params)->getBody(); + $result = DI::httpRequest()->post($ltree_blog, $params)->getBody(); Logger::log('libertree: ' . $result); } } diff --git a/ljpost/ljpost.php b/ljpost/ljpost.php index 4420775a8..a98087c2d 100644 --- a/ljpost/ljpost.php +++ b/ljpost/ljpost.php @@ -13,7 +13,6 @@ use Friendica\Core\Hook; use Friendica\Core\Logger; use Friendica\DI; use Friendica\Model\Tag; -use Friendica\Network\HTTPRequest; use Friendica\Util\DateTimeFormat; use Friendica\Util\XML; @@ -241,7 +240,7 @@ EOT; Logger::log('ljpost: data: ' . $xml, Logger::DATA); if ($lj_blog !== 'test') { - $x = HTTPRequest::post($lj_blog, $xml, ["Content-Type: text/xml"])->getBody(); + $x = DI::httpRequest()->post($lj_blog, $xml, ["Content-Type: text/xml"])->getBody(); } Logger::log('posted to livejournal: ' . ($x) ? $x : '', Logger::DEBUG); } diff --git a/wppost/wppost.php b/wppost/wppost.php index 0d860ef57..8cd134109 100644 --- a/wppost/wppost.php +++ b/wppost/wppost.php @@ -12,7 +12,6 @@ use Friendica\Core\Hook; use Friendica\Core\Logger; use Friendica\Database\DBA; use Friendica\DI; -use Friendica\Network\HTTPRequest; use Friendica\Util\Strings; use Friendica\Util\XML; @@ -338,7 +337,7 @@ EOT; Logger::log('wppost: data: ' . $xml, Logger::DATA); if ($wp_blog !== 'test') { - $x = HTTPRequest::post($wp_blog, $xml)->getBody(); + $x = DI::httpRequest()->post($wp_blog, $xml)->getBody(); } Logger::log('posted to wordpress: ' . (($x) ? $x : ''), Logger::DEBUG); } From fed6e3cde19ae2f864bb378fd484b96fac56ca05 Mon Sep 17 00:00:00 2001 From: nupplaPhil Date: Wed, 4 Mar 2020 22:19:59 +0100 Subject: [PATCH 4/9] Make "HTTPRequest::fetchUrlFull" dynamic --- mailstream/mailstream.php | 2 +- mastodoncustomemojis/mastodoncustomemojis.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mailstream/mailstream.php b/mailstream/mailstream.php index dbc9c4f08..4eaa5704c 100644 --- a/mailstream/mailstream.php +++ b/mailstream/mailstream.php @@ -169,7 +169,7 @@ function mailstream_do_images($a, &$item, &$attachments) { continue; } $cookiejar = tempnam(get_temppath(), 'cookiejar-mailstream-'); - $curlResult = HTTPRequest::fetchUrlFull($url, true, 0, '', $cookiejar); + $curlResult = DI::httpRequest()->fetchUrlFull($url, true, 0, '', $cookiejar); $attachments[$url] = [ 'data' => $curlResult->getBody(), 'guid' => hash("crc32", $url), diff --git a/mastodoncustomemojis/mastodoncustomemojis.php b/mastodoncustomemojis/mastodoncustomemojis.php index a0c06b97c..537cf46e3 100644 --- a/mastodoncustomemojis/mastodoncustomemojis.php +++ b/mastodoncustomemojis/mastodoncustomemojis.php @@ -90,7 +90,7 @@ function mastodoncustomemojis_fetch_custom_emojis_for_url($api_base_url) $api_url = $api_base_url . '/api/v1/custom_emojis'; - $fetchResult = HTTPRequest::fetchUrlFull($api_url); + $fetchResult = DI::httpRequest()->fetchUrlFull($api_url); if ($fetchResult->isSuccess()) { $emojis_array = json_decode($fetchResult->getBody(), true); From 40ff1d7fda9bde44420e4145bbca370664a97bbc Mon Sep 17 00:00:00 2001 From: nupplaPhil Date: Wed, 4 Mar 2020 22:20:27 +0100 Subject: [PATCH 5/9] Make "HTTPRequest::fetchUrl" dynamic --- curweather/curweather.php | 3 +-- geocoordinates/geocoordinates.php | 3 +-- geonames/geonames.php | 3 +-- jappixmini/jappixmini.php | 3 +-- leistungsschutzrecht/leistungsschutzrecht.php | 3 +-- statusnet/statusnet.php | 11 +++++------ twitter/twitter.php | 5 ++--- 7 files changed, 12 insertions(+), 19 deletions(-) diff --git a/curweather/curweather.php b/curweather/curweather.php index 017a67fa9..7757dba7e 100644 --- a/curweather/curweather.php +++ b/curweather/curweather.php @@ -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())); diff --git a/geocoordinates/geocoordinates.php b/geocoordinates/geocoordinates.php index a36cc1149..8641d2236 100644 --- a/geocoordinates/geocoordinates.php +++ b/geocoordinates/geocoordinates.php @@ -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); diff --git a/geonames/geonames.php b/geonames/geonames.php index 9a01980e7..28d716b5e 100644 --- a/geonames/geonames.php +++ b/geonames/geonames.php @@ -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; diff --git a/jappixmini/jappixmini.php b/jappixmini/jappixmini.php index 908870bb0..52ae56d07 100644 --- a/jappixmini/jappixmini.php +++ b/jappixmini/jappixmini.php @@ -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); diff --git a/leistungsschutzrecht/leistungsschutzrecht.php b/leistungsschutzrecht/leistungsschutzrecht.php index 142661a69..9bd1a68d0 100644 --- a/leistungsschutzrecht/leistungsschutzrecht.php +++ b/leistungsschutzrecht/leistungsschutzrecht.php @@ -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']; diff --git a/statusnet/statusnet.php b/statusnet/statusnet.php index 49ba2e452..a204f3e31 100644 --- a/statusnet/statusnet.php +++ b/statusnet/statusnet.php @@ -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); diff --git a/twitter/twitter.php b/twitter/twitter.php index 85647dea6..f93b12b44 100644 --- a/twitter/twitter.php +++ b/twitter/twitter.php @@ -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); From f36ca4fcf44ccc756061eefebf43116713b7c66e Mon Sep 17 00:00:00 2001 From: nupplaPhil Date: Wed, 4 Mar 2020 22:30:24 +0100 Subject: [PATCH 6/9] Move "Network::finalUrl" to "HTTPRequest" class --- statusnet/statusnet.php | 3 +-- twitter/twitter.php | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/statusnet/statusnet.php b/statusnet/statusnet.php index a204f3e31..24030ce6a 100644 --- a/statusnet/statusnet.php +++ b/statusnet/statusnet.php @@ -57,7 +57,6 @@ use Friendica\Model\Photo; use Friendica\Model\User; use Friendica\Protocol\Activity; use Friendica\Util\DateTimeFormat; -use Friendica\Util\Network; use Friendica\Util\Strings; function statusnet_install() @@ -1450,7 +1449,7 @@ function statusnet_convertmsg(App $a, $body) Logger::log("statusnet_convertmsg: expanding url " . $match[1], Logger::DEBUG); - $expanded_url = Network::finalUrl($match[1]); + $expanded_url = HTTPRequest::finalUrl($match[1]); Logger::log("statusnet_convertmsg: fetching data for " . $expanded_url, Logger::DEBUG); diff --git a/twitter/twitter.php b/twitter/twitter.php index f93b12b44..cea398421 100644 --- a/twitter/twitter.php +++ b/twitter/twitter.php @@ -89,7 +89,6 @@ use Friendica\Protocol\Activity; use Friendica\Util\ConfigFileLoader; use Friendica\Util\DateTimeFormat; use Friendica\Util\Images; -use Friendica\Util\Network; use Friendica\Util\Strings; require_once __DIR__ . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php'; @@ -1297,7 +1296,7 @@ function twitter_expand_entities($body, stdClass $status, $picture) $expanded_url = $url->expanded_url; - $final_url = Network::finalUrl($url->expanded_url); + $final_url = HTTPRequest::finalUrl($url->expanded_url); $oembed_data = OEmbed::fetchURL($final_url); From 90193bd02bff26759406c349bcd367bafa81fc6f Mon Sep 17 00:00:00 2001 From: nupplaPhil Date: Wed, 4 Mar 2020 22:33:31 +0100 Subject: [PATCH 7/9] Move "HTTPRequest::finalUrl" dynamic --- statusnet/statusnet.php | 2 +- twitter/twitter.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/statusnet/statusnet.php b/statusnet/statusnet.php index 24030ce6a..7ec3a2d5d 100644 --- a/statusnet/statusnet.php +++ b/statusnet/statusnet.php @@ -1449,7 +1449,7 @@ function statusnet_convertmsg(App $a, $body) Logger::log("statusnet_convertmsg: expanding url " . $match[1], Logger::DEBUG); - $expanded_url = HTTPRequest::finalUrl($match[1]); + $expanded_url = DI::httpRequest()->finalUrl($match[1]); Logger::log("statusnet_convertmsg: fetching data for " . $expanded_url, Logger::DEBUG); diff --git a/twitter/twitter.php b/twitter/twitter.php index cea398421..30195427d 100644 --- a/twitter/twitter.php +++ b/twitter/twitter.php @@ -1296,7 +1296,7 @@ function twitter_expand_entities($body, stdClass $status, $picture) $expanded_url = $url->expanded_url; - $final_url = HTTPRequest::finalUrl($url->expanded_url); + $final_url = DI::httpRequest()->finalUrl($url->expanded_url); $oembed_data = OEmbed::fetchURL($final_url); From 72c24efe5b1805c95d99ccfd891742d9178e87ae Mon Sep 17 00:00:00 2001 From: nupplaPhil Date: Wed, 4 Mar 2020 22:35:08 +0100 Subject: [PATCH 8/9] Rename "HTTPRequest::curl()" to HTTPRequest::get() --- discourse/discourse.php | 4 ++-- openstreetmap/openstreetmap.php | 2 +- pumpio/pumpio.php | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/discourse/discourse.php b/discourse/discourse.php index 5e64c173e..b3f95bbb4 100644 --- a/discourse/discourse.php +++ b/discourse/discourse.php @@ -114,7 +114,7 @@ function discourse_email_getmessage(App $a, &$message) function discourse_fetch_post($host, $topic, $pid) { $url = $host . '/t/' . $topic . '/' . $pid . '.json'; - $curlResult = DI::httpRequest()->curl($url); + $curlResult = DI::httpRequest()->get($url); if (!$curlResult->isSuccess()) { Logger::info('No success', ['url' => $url]); return false; @@ -151,7 +151,7 @@ function discourse_fetch_post_from_api(&$message, $post, $host) { $hostaddr = 'https://' . $host; $url = $hostaddr . '/posts/' . $post . '.json'; - $curlResult = DI::httpRequest()->curl($url); + $curlResult = DI::httpRequest()->get($url); if (!$curlResult->isSuccess()) { return false; } diff --git a/openstreetmap/openstreetmap.php b/openstreetmap/openstreetmap.php index ede71ccd4..efd0745ee 100644 --- a/openstreetmap/openstreetmap.php +++ b/openstreetmap/openstreetmap.php @@ -131,7 +131,7 @@ function openstreetmap_get_coordinates($a, &$b) $j = DI::cache()->get($cachekey); if (is_null($j)) { - $curlResult = DI::httpRequest()->curl($nomserver . $args); + $curlResult = DI::httpRequest()->get($nomserver . $args); if ($curlResult->isSuccess()) { $j = json_decode($curlResult->getBody(), true); DI::cache()->set($cachekey, $j, Duration::MONTH); diff --git a/pumpio/pumpio.php b/pumpio/pumpio.php index d85902841..2144257db 100644 --- a/pumpio/pumpio.php +++ b/pumpio/pumpio.php @@ -1604,7 +1604,7 @@ function pumpio_fetchallcomments(App $a, $uid, $id) function pumpio_reachable($url) { - return DI::httpRequest()->curl($url, false, ['timeout' => 10])->isSuccess(); + return DI::httpRequest()->get($url, false, ['timeout' => 10])->isSuccess(); } /* From 19b2c8d83315ba7bc024ec2b29ea87762bc1ffa6 Mon Sep 17 00:00:00 2001 From: nupplaPhil Date: Wed, 4 Mar 2020 22:35:39 +0100 Subject: [PATCH 9/9] Rename "fetchUrl" and "fetchUrlFull" to "fetch" and "fetchFull" --- curweather/curweather.php | 2 +- geocoordinates/geocoordinates.php | 2 +- geonames/geonames.php | 2 +- jappixmini/jappixmini.php | 2 +- leistungsschutzrecht/leistungsschutzrecht.php | 2 +- mailstream/mailstream.php | 3 +-- mastodoncustomemojis/mastodoncustomemojis.php | 3 +-- statusnet/statusnet.php | 10 +++++----- twitter/twitter.php | 4 ++-- 9 files changed, 14 insertions(+), 16 deletions(-) diff --git a/curweather/curweather.php b/curweather/curweather.php index 7757dba7e..575c5503a 100644 --- a/curweather/curweather.php +++ b/curweather/curweather.php @@ -48,7 +48,7 @@ function getWeather($loc, $units = 'metric', $lang = 'en', $appid = '', $cacheti } try { - $res = new SimpleXMLElement(DI::httpRequest()->fetchUrl($url)); + $res = new SimpleXMLElement(DI::httpRequest()->fetch($url)); } catch (Exception $e) { if (empty($_SESSION['curweather_notice_shown'])) { info(DI::l10n()->t('Error fetching weather data. Error was: '.$e->getMessage())); diff --git a/geocoordinates/geocoordinates.php b/geocoordinates/geocoordinates.php index 8641d2236..2bde405ca 100644 --- a/geocoordinates/geocoordinates.php +++ b/geocoordinates/geocoordinates.php @@ -52,7 +52,7 @@ function geocoordinates_resolve_item(&$item) return; } - $s = DI::httpRequest()->fetchUrl("https://api.opencagedata.com/geocode/v1/json?q=" . $coords[0] . "," . $coords[1] . "&key=" . $key . "&language=" . $language); + $s = DI::httpRequest()->fetch("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); diff --git a/geonames/geonames.php b/geonames/geonames.php index 28d716b5e..6536f9efa 100644 --- a/geonames/geonames.php +++ b/geonames/geonames.php @@ -77,7 +77,7 @@ function geonames_post_hook(App $a, array &$item) /* OK, we're allowed to do our stuff. */ - $s = DI::httpRequest()->fetchUrl('http://api.geonames.org/findNearbyPlaceName?lat=' . $coords[0] . '&lng=' . $coords[1] . '&username=' . $geo_account); + $s = DI::httpRequest()->fetch('http://api.geonames.org/findNearbyPlaceName?lat=' . $coords[0] . '&lng=' . $coords[1] . '&username=' . $geo_account); if (!$s) { return; diff --git a/jappixmini/jappixmini.php b/jappixmini/jappixmini.php index 52ae56d07..384b7798c 100644 --- a/jappixmini/jappixmini.php +++ b/jappixmini/jappixmini.php @@ -659,7 +659,7 @@ function jappixmini_cron(App $a, $d) try { // send request - $answer_json = DI::httpRequest()->fetchUrl($url); + $answer_json = DI::httpRequest()->fetch($url); // parse answer $answer = json_decode($answer_json); diff --git a/leistungsschutzrecht/leistungsschutzrecht.php b/leistungsschutzrecht/leistungsschutzrecht.php index 9bd1a68d0..eb25f550b 100644 --- a/leistungsschutzrecht/leistungsschutzrecht.php +++ b/leistungsschutzrecht/leistungsschutzrecht.php @@ -79,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 = DI::httpRequest()->fetchUrl($url); + $sitelist = DI::httpRequest()->fetch($url); $siteurls = explode(',', $sitelist); $whitelist = ['tagesschau.de', 'heute.de', 'wdr.de']; diff --git a/mailstream/mailstream.php b/mailstream/mailstream.php index 4eaa5704c..d09f913a1 100644 --- a/mailstream/mailstream.php +++ b/mailstream/mailstream.php @@ -13,7 +13,6 @@ use Friendica\Core\Renderer; use Friendica\Database\DBA; use Friendica\DI; use Friendica\Model\Item; -use Friendica\Network\HTTPRequest; use Friendica\Protocol\Activity; function mailstream_install() { @@ -169,7 +168,7 @@ function mailstream_do_images($a, &$item, &$attachments) { continue; } $cookiejar = tempnam(get_temppath(), 'cookiejar-mailstream-'); - $curlResult = DI::httpRequest()->fetchUrlFull($url, true, 0, '', $cookiejar); + $curlResult = DI::httpRequest()->fetchFull($url, true, 0, '', $cookiejar); $attachments[$url] = [ 'data' => $curlResult->getBody(), 'guid' => hash("crc32", $url), diff --git a/mastodoncustomemojis/mastodoncustomemojis.php b/mastodoncustomemojis/mastodoncustomemojis.php index 537cf46e3..a3cd0b97a 100644 --- a/mastodoncustomemojis/mastodoncustomemojis.php +++ b/mastodoncustomemojis/mastodoncustomemojis.php @@ -15,7 +15,6 @@ use Friendica\Core\Cache\Duration; use Friendica\Core\Hook; use Friendica\Core\Protocol; use Friendica\DI; -use Friendica\Network\HTTPRequest; use Friendica\Util\Proxy as ProxyUtils; function mastodoncustomemojis_install() @@ -90,7 +89,7 @@ function mastodoncustomemojis_fetch_custom_emojis_for_url($api_base_url) $api_url = $api_base_url . '/api/v1/custom_emojis'; - $fetchResult = DI::httpRequest()->fetchUrlFull($api_url); + $fetchResult = DI::httpRequest()->fetchFull($api_url); if ($fetchResult->isSuccess()) { $emojis_array = json_decode($fetchResult->getBody(), true); diff --git a/statusnet/statusnet.php b/statusnet/statusnet.php index 7ec3a2d5d..c213a4c37 100644 --- a/statusnet/statusnet.php +++ b/statusnet/statusnet.php @@ -154,7 +154,7 @@ function statusnet_settings_post(App $a, $post) foreach ($globalsn as $asn) { if ($asn['apiurl'] == $_POST['statusnet-preconf-apiurl']) { $apibase = $asn['apiurl']; - $c = DI::httpRequest()->fetchUrl($apibase . 'statusnet/version.xml'); + $c = DI::httpRequest()->fetch($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']); @@ -172,7 +172,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 = DI::httpRequest()->fetchUrl($apibase . 'statusnet/version.xml'); + $c = DI::httpRequest()->fetch($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']); @@ -182,7 +182,7 @@ function statusnet_settings_post(App $a, $post) } else { // the API path is not correct, maybe missing trailing / ? $apibase = $apibase . '/'; - $c = DI::httpRequest()->fetchUrl($apibase . 'statusnet/version.xml'); + $c = DI::httpRequest()->fetch($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']); @@ -612,7 +612,7 @@ function statusnet_post_hook(App $a, &$b) } if ($image != "") { - $img_str = DI::httpRequest()->fetchUrl($image); + $img_str = DI::httpRequest()->fetch($image); $tempfile = tempnam(get_temppath(), "cache"); file_put_contents($tempfile, $img_str); $postdata = ["status" => $msg, "media[]" => $tempfile]; @@ -1473,7 +1473,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 = DI::httpRequest()->fetchUrl($expanded_url, true, 4); + $img_str = DI::httpRequest()->fetch($expanded_url, true, 4); $tempfile = tempnam(get_temppath(), "cache"); file_put_contents($tempfile, $img_str); diff --git a/twitter/twitter.php b/twitter/twitter.php index 30195427d..7d9cbfda2 100644 --- a/twitter/twitter.php +++ b/twitter/twitter.php @@ -673,7 +673,7 @@ function twitter_post_hook(App $a, array &$b) continue; } - $img_str = DI::httpRequest()->fetchUrl($image['url']); + $img_str = DI::httpRequest()->fetch($image['url']); $tempfile = tempnam(get_temppath(), 'cache'); file_put_contents($tempfile, $img_str); @@ -1317,7 +1317,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 = DI::httpRequest()->fetchUrl($final_url, true, 4); + $img_str = DI::httpRequest()->fetch($final_url, true, 4); $tempfile = tempnam(get_temppath(), 'cache'); file_put_contents($tempfile, $img_str);