Move post/curl/fetchUrl/fetchUrlFull to own class "Network\HTTPRequest"

This commit is contained in:
nupplaPhil 2020-03-04 22:07:04 +01:00 committed by Hypolite Petovan
parent 31bd1a1ba0
commit 9640142a72
18 changed files with 50 additions and 45 deletions

View file

@ -11,7 +11,7 @@ use Friendica\Content\Text\BBCode;
use Friendica\Core\Hook; use Friendica\Core\Hook;
use Friendica\Core\Logger; use Friendica\Core\Logger;
use Friendica\DI; use Friendica\DI;
use Friendica\Util\Network; use Friendica\Network\HTTPRequest;
use Friendica\Util\XML; use Friendica\Util\XML;
function blogger_install() function blogger_install()
@ -225,7 +225,7 @@ EOT;
Logger::log('blogger: data: ' . $xml, Logger::DATA); Logger::log('blogger: data: ' . $xml, Logger::DATA);
if ($bl_blog !== 'test') { 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); Logger::log('posted to blogger: ' . (($x) ? $x : ''), Logger::DEBUG);

View file

@ -15,7 +15,7 @@ use Friendica\Core\Hook;
use Friendica\Core\Renderer; use Friendica\Core\Renderer;
use Friendica\Core\Session; use Friendica\Core\Session;
use Friendica\DI; use Friendica\DI;
use Friendica\Util\Network; use Friendica\Network\HTTPRequest;
use Friendica\Util\Proxy as ProxyUtils; use Friendica\Util\Proxy as ProxyUtils;
function curweather_install() function curweather_install()
@ -49,7 +49,7 @@ function getWeather($loc, $units = 'metric', $lang = 'en', $appid = '', $cacheti
} }
try { try {
$res = new SimpleXMLElement(Network::fetchUrl($url)); $res = new SimpleXMLElement(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()));

View file

@ -7,18 +7,19 @@
* Author: Michael Vogel <http://pirati.ca/profile/heluecht> * Author: Michael Vogel <http://pirati.ca/profile/heluecht>
* *
*/ */
use Friendica\App; use Friendica\App;
use Friendica\Content\Text\Markdown;
use Friendica\Core\Hook; use Friendica\Core\Hook;
use Friendica\Core\Logger; use Friendica\Core\Logger;
use Friendica\Core\Renderer;
use Friendica\Core\Protocol; use Friendica\Core\Protocol;
use Friendica\Core\Renderer;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\DI; use Friendica\DI;
use Friendica\Model\Contact; use Friendica\Model\Contact;
use Friendica\Content\Text\Markdown; use Friendica\Network\HTTPRequest;
use Friendica\Util\Network; use Friendica\Util\DateTimeFormat;
use Friendica\Util\Strings; use Friendica\Util\Strings;
Use Friendica\Util\DateTimeFormat;
/* Todo: /* Todo:
* - Obtaining API tokens to be able to read non public posts as well * - 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) function discourse_fetch_post($host, $topic, $pid)
{ {
$url = $host . '/t/' . $topic . '/' . $pid . '.json'; $url = $host . '/t/' . $topic . '/' . $pid . '.json';
$curlResult = Network::curl($url); $curlResult = HTTPRequest::curl($url);
if (!$curlResult->isSuccess()) { if (!$curlResult->isSuccess()) {
Logger::info('No success', ['url' => $url]); Logger::info('No success', ['url' => $url]);
return false; return false;
@ -151,7 +152,7 @@ function discourse_fetch_post_from_api(&$message, $post, $host)
{ {
$hostaddr = 'https://' . $host; $hostaddr = 'https://' . $host;
$url = $hostaddr . '/posts/' . $post . '.json'; $url = $hostaddr . '/posts/' . $post . '.json';
$curlResult = Network::curl($url); $curlResult = HTTPRequest::curl($url);
if (!$curlResult->isSuccess()) { if (!$curlResult->isSuccess()) {
return false; return false;
} }

View file

@ -15,8 +15,8 @@ use Friendica\Core\Logger;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\DI; use Friendica\DI;
use Friendica\Model\Tag; use Friendica\Model\Tag;
use Friendica\Network\HTTPRequest;
use Friendica\Util\DateTimeFormat; use Friendica\Util\DateTimeFormat;
use Friendica\Util\Network;
use Friendica\Util\XML; use Friendica\Util\XML;
function dwpost_install() function dwpost_install()
@ -231,7 +231,7 @@ EOT;
Logger::log('dwpost: data: ' . $xml, Logger::DATA); Logger::log('dwpost: data: ' . $xml, Logger::DATA);
if ($dw_blog !== 'test') { 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); Logger::log('posted to dreamwidth: ' . ($x) ? $x : '', Logger::DEBUG);

View file

@ -5,11 +5,12 @@
* Version: 0.1 * Version: 0.1
* Author: Michael Vogel <https://pirati.ca/profile/heluecht> * Author: Michael Vogel <https://pirati.ca/profile/heluecht>
*/ */
use Friendica\Core\Hook; use Friendica\Core\Hook;
use Friendica\Core\Logger; use Friendica\Core\Logger;
use Friendica\Core\Renderer; use Friendica\Core\Renderer;
use Friendica\DI; use Friendica\DI;
use Friendica\Util\Network; use Friendica\Network\HTTPRequest;
use Friendica\Util\Strings; use Friendica\Util\Strings;
function geocoordinates_install() function geocoordinates_install()
@ -52,7 +53,7 @@ function geocoordinates_resolve_item(&$item)
return; 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) { if (!$s) {
Logger::log("API could not be queried", Logger::DEBUG); Logger::log("API could not be queried", Logger::DEBUG);

View file

@ -11,8 +11,8 @@ use Friendica\Core\Hook;
use Friendica\Core\Logger; use Friendica\Core\Logger;
use Friendica\Core\Renderer; use Friendica\Core\Renderer;
use Friendica\DI; use Friendica\DI;
use Friendica\Network\HTTPRequest;
use Friendica\Util\ConfigFileLoader; use Friendica\Util\ConfigFileLoader;
use Friendica\Util\Network;
use Friendica\Util\XML; use Friendica\Util\XML;
function geonames_install() function geonames_install()
@ -78,7 +78,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 = 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) { if (!$s) {
return; return;

View file

@ -13,8 +13,8 @@ use Friendica\Core\Hook;
use Friendica\Core\Logger; use Friendica\Core\Logger;
use Friendica\DI; use Friendica\DI;
use Friendica\Model\Tag; use Friendica\Model\Tag;
use Friendica\Network\HTTPRequest;
use Friendica\Util\DateTimeFormat; use Friendica\Util\DateTimeFormat;
use Friendica\Util\Network;
use Friendica\Util\XML; use Friendica\Util\XML;
function ijpost_install() function ijpost_install()
@ -229,7 +229,7 @@ EOT;
Logger::log('ijpost: data: ' . $xml, Logger::DATA); Logger::log('ijpost: data: ' . $xml, Logger::DATA);
if ($ij_blog !== 'test') { 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); Logger::log('posted to insanejournal: ' . $x ? $x : '', Logger::DEBUG);
} }

View file

@ -69,7 +69,7 @@ use Friendica\Core\Protocol;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\DI; use Friendica\DI;
use Friendica\Model\User; use Friendica\Model\User;
use Friendica\Util\Network; use Friendica\Network\HTTPRequest;
function jappixmini_install() function jappixmini_install()
{ {
@ -660,7 +660,7 @@ function jappixmini_cron(App $a, $d)
try { try {
// send request // send request
$answer_json = Network::fetchUrl($url); $answer_json = HTTPRequest::fetchUrl($url);
// parse answer // parse answer
$answer = json_decode($answer_json); $answer = json_decode($answer_json);

View file

@ -5,10 +5,11 @@
* Version: 0.1 * Version: 0.1
* Author: Michael Vogel <https://pirati.ca/profile/heluecht> * Author: Michael Vogel <https://pirati.ca/profile/heluecht>
*/ */
use Friendica\Core\Hook; use Friendica\Core\Hook;
use Friendica\Core\Logger; use Friendica\Core\Logger;
use Friendica\DI; use Friendica\DI;
use Friendica\Util\Network; use Friendica\Network\HTTPRequest;
function leistungsschutzrecht_install() { function leistungsschutzrecht_install() {
Hook::register('cron', 'addon/leistungsschutzrecht/leistungsschutzrecht.php', 'leistungsschutzrecht_cron'); 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 // 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 = Network::fetchUrl($url); $sitelist = HTTPRequest::fetchUrl($url);
$siteurls = explode(',', $sitelist); $siteurls = explode(',', $sitelist);
$whitelist = ['tagesschau.de', 'heute.de', 'wdr.de']; $whitelist = ['tagesschau.de', 'heute.de', 'wdr.de'];

View file

@ -12,7 +12,7 @@ use Friendica\Core\Hook;
use Friendica\Core\Logger; use Friendica\Core\Logger;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\DI; use Friendica\DI;
use Friendica\Util\Network; use Friendica\Network\HTTPRequest;
function libertree_install() function libertree_install()
{ {
@ -243,7 +243,7 @@ function libertree_send(&$a,&$b) {
// 'token' => $ltree_api_token // 'token' => $ltree_api_token
]; ];
$result = Network::post($ltree_blog, $params)->getBody(); $result = HTTPRequest::post($ltree_blog, $params)->getBody();
Logger::log('libertree: ' . $result); Logger::log('libertree: ' . $result);
} }
} }

View file

@ -13,8 +13,8 @@ use Friendica\Core\Hook;
use Friendica\Core\Logger; use Friendica\Core\Logger;
use Friendica\DI; use Friendica\DI;
use Friendica\Model\Tag; use Friendica\Model\Tag;
use Friendica\Network\HTTPRequest;
use Friendica\Util\DateTimeFormat; use Friendica\Util\DateTimeFormat;
use Friendica\Util\Network;
use Friendica\Util\XML; use Friendica\Util\XML;
function ljpost_install() { function ljpost_install() {
@ -241,7 +241,7 @@ EOT;
Logger::log('ljpost: data: ' . $xml, Logger::DATA); Logger::log('ljpost: data: ' . $xml, Logger::DATA);
if ($lj_blog !== 'test') { 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); Logger::log('posted to livejournal: ' . ($x) ? $x : '', Logger::DEBUG);
} }

View file

@ -12,9 +12,9 @@ use Friendica\Core\Logger;
use Friendica\Core\Renderer; use Friendica\Core\Renderer;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\DI; use Friendica\DI;
use Friendica\Protocol\Activity;
use Friendica\Util\Network;
use Friendica\Model\Item; use Friendica\Model\Item;
use Friendica\Network\HTTPRequest;
use Friendica\Protocol\Activity;
function mailstream_install() { function mailstream_install() {
Hook::register('addon_settings', 'addon/mailstream/mailstream.php', 'mailstream_addon_settings'); Hook::register('addon_settings', 'addon/mailstream/mailstream.php', 'mailstream_addon_settings');
@ -169,7 +169,7 @@ function mailstream_do_images($a, &$item, &$attachments) {
continue; continue;
} }
$cookiejar = tempnam(get_temppath(), 'cookiejar-mailstream-'); $cookiejar = tempnam(get_temppath(), 'cookiejar-mailstream-');
$curlResult = Network::fetchUrlFull($url, true, 0, '', $cookiejar); $curlResult = HTTPRequest::fetchUrlFull($url, true, 0, '', $cookiejar);
$attachments[$url] = [ $attachments[$url] = [
'data' => $curlResult->getBody(), 'data' => $curlResult->getBody(),
'guid' => hash("crc32", $url), 'guid' => hash("crc32", $url),

View file

@ -15,7 +15,7 @@ use Friendica\Core\Cache\Duration;
use Friendica\Core\Hook; use Friendica\Core\Hook;
use Friendica\Core\Protocol; use Friendica\Core\Protocol;
use Friendica\DI; use Friendica\DI;
use Friendica\Util\Network; use Friendica\Network\HTTPRequest;
use Friendica\Util\Proxy as ProxyUtils; use Friendica\Util\Proxy as ProxyUtils;
function mastodoncustomemojis_install() 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'; $api_url = $api_base_url . '/api/v1/custom_emojis';
$fetchResult = Network::fetchUrlFull($api_url); $fetchResult = HTTPRequest::fetchUrlFull($api_url);
if ($fetchResult->isSuccess()) { if ($fetchResult->isSuccess()) {
$emojis_array = json_decode($fetchResult->getBody(), true); $emojis_array = json_decode($fetchResult->getBody(), true);

View file

@ -9,13 +9,13 @@
* *
*/ */
use Friendica\DI;
use Friendica\Core\Cache\Duration; use Friendica\Core\Cache\Duration;
use Friendica\Core\Hook; use Friendica\Core\Hook;
use Friendica\Core\Logger; use Friendica\Core\Logger;
use Friendica\Core\Renderer; use Friendica\Core\Renderer;
use Friendica\DI;
use Friendica\Network\HTTPRequest;
use Friendica\Util\ConfigFileLoader; use Friendica\Util\ConfigFileLoader;
use Friendica\Util\Network;
use Friendica\Util\Strings; use Friendica\Util\Strings;
const OSM_TMS = 'https://www.openstreetmap.org'; const OSM_TMS = 'https://www.openstreetmap.org';
@ -132,7 +132,7 @@ function openstreetmap_get_coordinates($a, &$b)
$j = DI::cache()->get($cachekey); $j = DI::cache()->get($cachekey);
if (is_null($j)) { if (is_null($j)) {
$curlResult = Network::curl($nomserver . $args); $curlResult = HTTPRequest::curl($nomserver . $args);
if ($curlResult->isSuccess()) { if ($curlResult->isSuccess()) {
$j = json_decode($curlResult->getBody(), true); $j = json_decode($curlResult->getBody(), true);
DI::cache()->set($cachekey, $j, Duration::MONTH); DI::cache()->set($cachekey, $j, Duration::MONTH);

View file

@ -19,11 +19,11 @@ use Friendica\Model\Contact;
use Friendica\Model\Group; use Friendica\Model\Group;
use Friendica\Model\Item; use Friendica\Model\Item;
use Friendica\Model\User; use Friendica\Model\User;
use Friendica\Network\HTTPRequest;
use Friendica\Protocol\Activity; use Friendica\Protocol\Activity;
use Friendica\Protocol\ActivityNamespace; use Friendica\Protocol\ActivityNamespace;
use Friendica\Util\ConfigFileLoader; use Friendica\Util\ConfigFileLoader;
use Friendica\Util\DateTimeFormat; use Friendica\Util\DateTimeFormat;
use Friendica\Util\Network;
use Friendica\Util\Strings; use Friendica\Util\Strings;
use Friendica\Util\XML; use Friendica\Util\XML;
@ -1605,7 +1605,7 @@ function pumpio_fetchallcomments(App $a, $uid, $id)
function pumpio_reachable($url) function pumpio_reachable($url)
{ {
return Network::curl($url, false, ['timeout' => 10])->isSuccess(); return HTTPRequest::curl($url, false, ['timeout' => 10])->isSuccess();
} }
/* /*

View file

@ -55,6 +55,7 @@ use Friendica\Model\Item;
use Friendica\Model\ItemContent; use Friendica\Model\ItemContent;
use Friendica\Model\Photo; use Friendica\Model\Photo;
use Friendica\Model\User; use Friendica\Model\User;
use Friendica\Network\HTTPRequest;
use Friendica\Protocol\Activity; use Friendica\Protocol\Activity;
use Friendica\Util\DateTimeFormat; use Friendica\Util\DateTimeFormat;
use Friendica\Util\Network; use Friendica\Util\Network;
@ -155,7 +156,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 = Network::fetchUrl($apibase . 'statusnet/version.xml'); $c = 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 +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 // 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 = Network::fetchUrl($apibase . 'statusnet/version.xml'); $c = 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 +184,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 = Network::fetchUrl($apibase . 'statusnet/version.xml'); $c = 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 +614,7 @@ function statusnet_post_hook(App $a, &$b)
} }
if ($image != "") { if ($image != "") {
$img_str = Network::fetchUrl($image); $img_str = 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];
@ -1474,7 +1475,7 @@ function statusnet_convertmsg(App $a, $body)
} 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 = Network::fetchUrl($expanded_url, true, 4); $img_str = 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);

View file

@ -85,6 +85,7 @@ use Friendica\Model\ItemContent;
use Friendica\Model\ItemURI; use Friendica\Model\ItemURI;
use Friendica\Model\Tag; use Friendica\Model\Tag;
use Friendica\Model\User; use Friendica\Model\User;
use Friendica\Network\HTTPRequest;
use Friendica\Protocol\Activity; use Friendica\Protocol\Activity;
use Friendica\Util\ConfigFileLoader; use Friendica\Util\ConfigFileLoader;
use Friendica\Util\DateTimeFormat; use Friendica\Util\DateTimeFormat;
@ -674,7 +675,7 @@ function twitter_post_hook(App $a, array &$b)
continue; continue;
} }
$img_str = Network::fetchUrl($image['url']); $img_str = 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);
@ -1318,7 +1319,7 @@ function twitter_expand_entities($body, stdClass $status, $picture)
} elseif ($oembed_data->type != 'link') { } elseif ($oembed_data->type != 'link') {
$replace = '[url=' . $expanded_url . ']' . $url->display_url . '[/url]'; $replace = '[url=' . $expanded_url . ']' . $url->display_url . '[/url]';
} else { } else {
$img_str = Network::fetchUrl($final_url, true, 4); $img_str = 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);

View file

@ -12,7 +12,7 @@ use Friendica\Core\Hook;
use Friendica\Core\Logger; use Friendica\Core\Logger;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\DI; use Friendica\DI;
use Friendica\Util\Network; use Friendica\Network\HTTPRequest;
use Friendica\Util\Strings; use Friendica\Util\Strings;
use Friendica\Util\XML; use Friendica\Util\XML;
@ -338,7 +338,7 @@ EOT;
Logger::log('wppost: data: ' . $xml, Logger::DATA); Logger::log('wppost: data: ' . $xml, Logger::DATA);
if ($wp_blog !== 'test') { 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); Logger::log('posted to wordpress: ' . (($x) ? $x : ''), Logger::DEBUG);
} }