Make "HTTPRequest::fetchUrl" dynamic

This commit is contained in:
nupplaPhil 2020-03-04 22:20:27 +01:00 committed by Hypolite Petovan
parent fed6e3cde1
commit 40ff1d7fda
7 changed files with 12 additions and 19 deletions

View 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);