mirror of
https://git.friendi.ca/friendica/friendica-addons.git
synced 2025-04-29 02:14:23 +02:00
Merge pull request #1006 from MrPetovan/task/curl_DI
Introduce "HTTPRequest" class
This commit is contained in:
commit
2c69a9c359
18 changed files with 34 additions and 49 deletions
|
@ -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()
|
||||
|
@ -155,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 = Network::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']);
|
||||
|
@ -173,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 = Network::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']);
|
||||
|
@ -183,7 +182,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 = 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']);
|
||||
|
@ -611,7 +610,7 @@ function statusnet_post_hook(App $a, &$b)
|
|||
}
|
||||
|
||||
if ($image != "") {
|
||||
$img_str = Network::fetchUrl($image);
|
||||
$img_str = DI::httpRequest()->fetch($image);
|
||||
$tempfile = tempnam(get_temppath(), "cache");
|
||||
file_put_contents($tempfile, $img_str);
|
||||
$postdata = ["status" => $msg, "media[]" => $tempfile];
|
||||
|
@ -1448,7 +1447,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 = DI::httpRequest()->finalUrl($match[1]);
|
||||
|
||||
Logger::log("statusnet_convertmsg: fetching data for " . $expanded_url, Logger::DEBUG);
|
||||
|
||||
|
@ -1472,7 +1471,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 = DI::httpRequest()->fetch($expanded_url, true, 4);
|
||||
|
||||
$tempfile = tempnam(get_temppath(), "cache");
|
||||
file_put_contents($tempfile, $img_str);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue