mirror of
https://git.friendi.ca/friendica/friendica-addons.git
synced 2025-07-15 21:08:49 +00:00
Make "HTTPRequest::fetchUrl" dynamic
This commit is contained in:
parent
f4cfdb4f5f
commit
58116f037e
7 changed files with 12 additions and 12 deletions
|
@ -50,7 +50,7 @@ function getWeather($loc, $units = 'metric', $lang = 'en', $appid = '', $cacheti
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$res = new SimpleXMLElement(HTTPRequest::fetchUrl($url));
|
$res = new SimpleXMLElement(DI::httpRequest()->fetchUrl($url));
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
if (empty($_SESSION['curweather_notice_shown'])) {
|
if (empty($_SESSION['curweather_notice_shown'])) {
|
||||||
info(DI::l10n()->t('Error fetching weather data. Error was: '.$e->getMessage()));
|
info(DI::l10n()->t('Error fetching weather data. Error was: '.$e->getMessage()));
|
||||||
|
|
|
@ -53,7 +53,7 @@ function geocoordinates_resolve_item(&$item)
|
||||||
return;
|
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) {
|
if (!$s) {
|
||||||
Logger::log("API could not be queried", Logger::DEBUG);
|
Logger::log("API could not be queried", Logger::DEBUG);
|
||||||
|
|
|
@ -79,7 +79,7 @@ function geonames_post_hook(App $a, array &$item)
|
||||||
|
|
||||||
/* OK, we're allowed to do our stuff. */
|
/* 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) {
|
if (!$s) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -661,7 +661,7 @@ function jappixmini_cron(App $a, $d)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// send request
|
// send request
|
||||||
$answer_json = HTTPRequest::fetchUrl($url);
|
$answer_json = DI::httpRequest()->fetchUrl($url);
|
||||||
|
|
||||||
// parse answer
|
// parse answer
|
||||||
$answer = json_decode($answer_json);
|
$answer = json_decode($answer_json);
|
||||||
|
|
|
@ -80,7 +80,7 @@ function leistungsschutzrecht_fetchsites()
|
||||||
{
|
{
|
||||||
// This list works - but question is how current it is
|
// This list works - but question is how current it is
|
||||||
$url = "http://leistungsschutzrecht-stoppen.d-64.org/blacklist.txt";
|
$url = "http://leistungsschutzrecht-stoppen.d-64.org/blacklist.txt";
|
||||||
$sitelist = HTTPRequest::fetchUrl($url);
|
$sitelist = DI::httpRequest()->fetchUrl($url);
|
||||||
$siteurls = explode(',', $sitelist);
|
$siteurls = explode(',', $sitelist);
|
||||||
|
|
||||||
$whitelist = ['tagesschau.de', 'heute.de', 'wdr.de'];
|
$whitelist = ['tagesschau.de', 'heute.de', 'wdr.de'];
|
||||||
|
|
|
@ -155,7 +155,7 @@ function statusnet_settings_post(App $a, $post)
|
||||||
foreach ($globalsn as $asn) {
|
foreach ($globalsn as $asn) {
|
||||||
if ($asn['apiurl'] == $_POST['statusnet-preconf-apiurl']) {
|
if ($asn['apiurl'] == $_POST['statusnet-preconf-apiurl']) {
|
||||||
$apibase = $asn['apiurl'];
|
$apibase = $asn['apiurl'];
|
||||||
$c = HTTPRequest::fetchUrl($apibase . 'statusnet/version.xml');
|
$c = DI::httpRequest()->fetchUrl($apibase . 'statusnet/version.xml');
|
||||||
if (strlen($c) > 0) {
|
if (strlen($c) > 0) {
|
||||||
DI::pConfig()->set(local_user(), 'statusnet', 'consumerkey', $asn['consumerkey']);
|
DI::pConfig()->set(local_user(), 'statusnet', 'consumerkey', $asn['consumerkey']);
|
||||||
DI::pConfig()->set(local_user(), 'statusnet', 'consumersecret', $asn['consumersecret']);
|
DI::pConfig()->set(local_user(), 'statusnet', 'consumersecret', $asn['consumersecret']);
|
||||||
|
@ -173,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
|
// 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 ;-)
|
// resign quickly after this one try to fix the path ;-)
|
||||||
$apibase = $_POST['statusnet-baseapi'];
|
$apibase = $_POST['statusnet-baseapi'];
|
||||||
$c = HTTPRequest::fetchUrl($apibase . 'statusnet/version.xml');
|
$c = DI::httpRequest()->fetchUrl($apibase . 'statusnet/version.xml');
|
||||||
if (strlen($c) > 0) {
|
if (strlen($c) > 0) {
|
||||||
// ok the API path is correct, let's save the settings
|
// ok the API path is correct, let's save the settings
|
||||||
DI::pConfig()->set(local_user(), 'statusnet', 'consumerkey', $_POST['statusnet-consumerkey']);
|
DI::pConfig()->set(local_user(), 'statusnet', 'consumerkey', $_POST['statusnet-consumerkey']);
|
||||||
|
@ -183,7 +183,7 @@ function statusnet_settings_post(App $a, $post)
|
||||||
} else {
|
} else {
|
||||||
// the API path is not correct, maybe missing trailing / ?
|
// the API path is not correct, maybe missing trailing / ?
|
||||||
$apibase = $apibase . '/';
|
$apibase = $apibase . '/';
|
||||||
$c = HTTPRequest::fetchUrl($apibase . 'statusnet/version.xml');
|
$c = DI::httpRequest()->fetchUrl($apibase . 'statusnet/version.xml');
|
||||||
if (strlen($c) > 0) {
|
if (strlen($c) > 0) {
|
||||||
// ok the API path is now correct, let's save the settings
|
// ok the API path is now correct, let's save the settings
|
||||||
DI::pConfig()->set(local_user(), 'statusnet', 'consumerkey', $_POST['statusnet-consumerkey']);
|
DI::pConfig()->set(local_user(), 'statusnet', 'consumerkey', $_POST['statusnet-consumerkey']);
|
||||||
|
@ -613,7 +613,7 @@ function statusnet_post_hook(App $a, &$b)
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($image != "") {
|
if ($image != "") {
|
||||||
$img_str = HTTPRequest::fetchUrl($image);
|
$img_str = DI::httpRequest()->fetchUrl($image);
|
||||||
$tempfile = tempnam(get_temppath(), "cache");
|
$tempfile = tempnam(get_temppath(), "cache");
|
||||||
file_put_contents($tempfile, $img_str);
|
file_put_contents($tempfile, $img_str);
|
||||||
$postdata = ["status" => $msg, "media[]" => $tempfile];
|
$postdata = ["status" => $msg, "media[]" => $tempfile];
|
||||||
|
@ -1476,7 +1476,7 @@ function statusnet_convertmsg(App $a, $body, $no_tags = false)
|
||||||
} elseif ($oembed_data->type != "link") {
|
} elseif ($oembed_data->type != "link") {
|
||||||
$body = str_replace($search, "[url=" . $expanded_url . "]" . $expanded_url . "[/url]", $body);
|
$body = str_replace($search, "[url=" . $expanded_url . "]" . $expanded_url . "[/url]", $body);
|
||||||
} else {
|
} else {
|
||||||
$img_str = HTTPRequest::fetchUrl($expanded_url, true, 4);
|
$img_str = DI::httpRequest()->fetchUrl($expanded_url, true, 4);
|
||||||
|
|
||||||
$tempfile = tempnam(get_temppath(), "cache");
|
$tempfile = tempnam(get_temppath(), "cache");
|
||||||
file_put_contents($tempfile, $img_str);
|
file_put_contents($tempfile, $img_str);
|
||||||
|
|
|
@ -656,7 +656,7 @@ function twitter_post_hook(App $a, array &$b)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$img_str = HTTPRequest::fetchUrl($image['url']);
|
$img_str = DI::httpRequest()->fetchUrl($image['url']);
|
||||||
|
|
||||||
$tempfile = tempnam(get_temppath(), 'cache');
|
$tempfile = tempnam(get_temppath(), 'cache');
|
||||||
file_put_contents($tempfile, $img_str);
|
file_put_contents($tempfile, $img_str);
|
||||||
|
@ -1202,7 +1202,7 @@ function twitter_expand_entities(App $a, $body, $item, $picture)
|
||||||
} elseif ($oembed_data->type != 'link') {
|
} elseif ($oembed_data->type != 'link') {
|
||||||
$body = str_replace($url->url, '[url=' . $expanded_url . ']' . $url->display_url . '[/url]', $body);
|
$body = str_replace($url->url, '[url=' . $expanded_url . ']' . $url->display_url . '[/url]', $body);
|
||||||
} else {
|
} else {
|
||||||
$img_str = HTTPRequest::fetchUrl($final_url, true, 4);
|
$img_str = DI::httpRequest()->fetchUrl($final_url, true, 4);
|
||||||
|
|
||||||
$tempfile = tempnam(get_temppath(), 'cache');
|
$tempfile = tempnam(get_temppath(), 'cache');
|
||||||
file_put_contents($tempfile, $img_str);
|
file_put_contents($tempfile, $img_str);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue