[various] Rename ICanHandleHttpResponses->getBody to getBodyString #1456

Merged
heluecht merged 1 commit from MrPetovan/friendica-addons:bug/deprecated into develop 2024-01-13 21:38:32 +01:00
13 changed files with 26 additions and 26 deletions

View file

@ -1736,13 +1736,13 @@ function bluesky_post(int $uid, string $url, string $params, array $headers): ?s
} }
if (!$curlResult->isSuccess()) { if (!$curlResult->isSuccess()) {
Logger::notice('API Error', ['error' => json_decode($curlResult->getBody()) ?: $curlResult->getBody()]); Logger::notice('API Error', ['error' => json_decode($curlResult->getBodyString()) ?: $curlResult->getBodyString()]);
DI::pConfig()->set($uid, 'bluesky', 'status', BLUEKSY_STATUS_API_FAIL); DI::pConfig()->set($uid, 'bluesky', 'status', BLUEKSY_STATUS_API_FAIL);
return null; return null;
} }
DI::pConfig()->set($uid, 'bluesky', 'status', BLUEKSY_STATUS_SUCCESS); DI::pConfig()->set($uid, 'bluesky', 'status', BLUEKSY_STATUS_SUCCESS);
return json_decode($curlResult->getBody()); return json_decode($curlResult->getBodyString());
} }
function bluesky_xrpc_get(int $uid, string $url, array $parameters = []): ?stdClass function bluesky_xrpc_get(int $uid, string $url, array $parameters = []): ?stdClass
@ -1767,9 +1767,9 @@ function bluesky_get(string $url, string $accept_content = HttpClientAccept::DEF
} }
if (!$curlResult->isSuccess()) { if (!$curlResult->isSuccess()) {
Logger::notice('API Error', ['error' => json_decode($curlResult->getBody()) ?: $curlResult->getBody()]); Logger::notice('API Error', ['error' => json_decode($curlResult->getBodyString()) ?: $curlResult->getBodyString()]);
return null; return null;
} }
return json_decode($curlResult->getBody()); return json_decode($curlResult->getBodyString());
} }

View file

@ -126,7 +126,7 @@ function discourse_fetch_post($host, $topic, $pid)
return false; return false;
} }
$raw = $curlResult->getBody(); $raw = $curlResult->getBodyString();
$data = json_decode($raw, true); $data = json_decode($raw, true);
$posts = $data['post_stream']['posts']; $posts = $data['post_stream']['posts'];
foreach($posts as $post) { foreach($posts as $post) {
@ -162,7 +162,7 @@ function discourse_fetch_post_from_api(&$message, $post, $host)
return false; return false;
} }
$raw = $curlResult->getBody(); $raw = $curlResult->getBodyString();
$data = json_decode($raw, true); $data = json_decode($raw, true);
if (empty($data)) { if (empty($data)) {
return false; return false;

View file

@ -192,7 +192,7 @@ EOT;
Logger::debug('dwpost: data: ' . $xml); Logger::debug('dwpost: data: ' . $xml);
if ($dw_blog !== 'test') { if ($dw_blog !== 'test') {
$x = DI::httpClient()->post($dw_blog, $xml, ['Content-Type' => 'text/xml'])->getBody(); $x = DI::httpClient()->post($dw_blog, $xml, ['Content-Type' => 'text/xml'])->getBodyString();
} }
Logger::info('posted to dreamwidth: ' . ($x) ? $x : ''); Logger::info('posted to dreamwidth: ' . ($x) ? $x : '');

View file

@ -186,7 +186,7 @@ EOT;
Logger::debug('ijpost: data: ' . $xml); Logger::debug('ijpost: data: ' . $xml);
if ($ij_blog !== 'test') { if ($ij_blog !== 'test') {
$x = DI::httpClient()->post($ij_blog, $xml, ['Content-Type' => 'text/xml'])->getBody(); $x = DI::httpClient()->post($ij_blog, $xml, ['Content-Type' => 'text/xml'])->getBodyString();
} }
Logger::info('posted to insanejournal: ' . $x ? $x : ''); Logger::info('posted to insanejournal: ' . $x ? $x : '');
} }

View file

@ -201,7 +201,7 @@ function libertree_send(array &$b)
// 'token' => $ltree_api_token // 'token' => $ltree_api_token
]; ];
$result = DI::httpClient()->post($ltree_blog, $params)->getBody(); $result = DI::httpClient()->post($ltree_blog, $params)->getBodyString();
Logger::notice('libertree: ' . $result); Logger::notice('libertree: ' . $result);
} }
} }

View file

@ -207,7 +207,7 @@ EOT;
Logger::debug('ljpost: data: ' . $xml); Logger::debug('ljpost: data: ' . $xml);
if ($lj_blog !== 'test') { if ($lj_blog !== 'test') {
$x = DI::httpClient()->post($lj_blog, $xml, ['Content-Type' => 'text/xml'])->getBody(); $x = DI::httpClient()->post($lj_blog, $xml, ['Content-Type' => 'text/xml'])->getBodyString();
} }
Logger::info('posted to livejournal: ' . ($x) ? $x : ''); Logger::info('posted to livejournal: ' . ($x) ? $x : '');

View file

@ -221,7 +221,7 @@ function mailstream_do_images(array &$item, array &$attachments)
continue; continue;
} }
$attachments[$url] = [ $attachments[$url] = [
'data' => $curlResult->getBody(), 'data' => $curlResult->getBodyString(),
'guid' => hash('crc32', $url), 'guid' => hash('crc32', $url),
'filename' => basename($components['path']), 'filename' => basename($components['path']),
'type' => $curlResult->getContentType() 'type' => $curlResult->getContentType()

View file

@ -82,7 +82,7 @@ function mastodoncustomemojis_fetch_custom_emojis_for_url($api_base_url)
$fetchResult = DI::httpClient()->fetchFull($api_url); $fetchResult = DI::httpClient()->fetchFull($api_url);
if ($fetchResult->isSuccess()) { if ($fetchResult->isSuccess()) {
$emojis_array = json_decode($fetchResult->getBody(), true); $emojis_array = json_decode($fetchResult->getBodyString(), true);
if (is_array($emojis_array) && count($emojis_array)) { if (is_array($emojis_array) && count($emojis_array)) {
foreach ($emojis_array as $emoji) { foreach ($emojis_array as $emoji) {

View file

@ -121,7 +121,7 @@ function openstreetmap_get_coordinates(array &$b)
if (is_null($j)) { if (is_null($j)) {
$curlResult = DI::httpClient()->get($nomserver . $args); $curlResult = DI::httpClient()->get($nomserver . $args);
if ($curlResult->isSuccess()) { if ($curlResult->isSuccess()) {
$j = json_decode($curlResult->getBody(), true); $j = json_decode($curlResult->getBodyString(), true);
DI::cache()->set($cachekey, $j, Duration::MONTH); DI::cache()->set($cachekey, $j, Duration::MONTH);
} }
} }

View file

@ -1244,7 +1244,7 @@ function tumblr_get_contact_by_url(string $url, int $uid): ?array
} catch (\Exception $e) { } catch (\Exception $e) {
return null; return null;
} }
$html = $curlResult->getBody(); $html = $curlResult->getBodyString();
if (empty($html)) { if (empty($html)) {
return null; return null;
} }
@ -1372,7 +1372,7 @@ function tumblr_delete(int $uid, string $url, array $parameters): stdClass
*/ */
function tumblr_format_result(ICanHandleHttpResponses $curlResult): stdClass function tumblr_format_result(ICanHandleHttpResponses $curlResult): stdClass
{ {
$result = json_decode($curlResult->getBody()); $result = json_decode($curlResult->getBodyString());
if (empty($result) || empty($result->meta)) { if (empty($result) || empty($result->meta)) {
$result = new stdClass; $result = new stdClass;
$result->meta = new stdClass; $result->meta = new stdClass;
@ -1426,11 +1426,11 @@ function tumblr_get_token(int $uid, string $code = ''): string
$curlResult = DI::httpClient()->post('https://api.tumblr.com/v2/oauth2/token', $parameters); $curlResult = DI::httpClient()->post('https://api.tumblr.com/v2/oauth2/token', $parameters);
if (!$curlResult->isSuccess()) { if (!$curlResult->isSuccess()) {
Logger::info('Error fetching token', ['uid' => $uid, 'code' => $code, 'result' => $curlResult->getBody(), 'parameters' => $parameters]); Logger::info('Error fetching token', ['uid' => $uid, 'code' => $code, 'result' => $curlResult->getBodyString(), 'parameters' => $parameters]);
return ''; return '';
} }
$result = json_decode($curlResult->getBody()); $result = json_decode($curlResult->getBodyString());
if (empty($result)) { if (empty($result)) {
Logger::info('Invalid result when updating token', ['uid' => $uid]); Logger::info('Invalid result when updating token', ['uid' => $uid]);
return ''; return '';
@ -1479,7 +1479,7 @@ function tumblr_exchange_token(int $uid): stdClass
]); ]);
$response = $client->post('oauth2/exchange', ['auth' => 'oauth']); $response = $client->post('oauth2/exchange', ['auth' => 'oauth']);
return json_decode($response->getBody()->getContents()); return json_decode($response->getBodyString()->getContents());
} catch (RequestException $exception) { } catch (RequestException $exception) {
Logger::notice('Exchange failed', ['code' => $exception->getCode(), 'message' => $exception->getMessage()]); Logger::notice('Exchange failed', ['code' => $exception->getCode(), 'message' => $exception->getMessage()]);
return new stdClass; return new stdClass;

View file

@ -362,7 +362,7 @@ function twitter_post(int $uid, string $url, string $type, array $data): stdClas
]); ]);
$response = $client->post($url, ['auth' => 'oauth', $type => $data]); $response = $client->post($url, ['auth' => 'oauth', $type => $data]);
$body = $response->getBody()->getContents(); $body = $response->getBodyString()->getContents();
$status = [ $status = [
'code' => $response->getStatusCode(), 'code' => $response->getStatusCode(),
@ -399,7 +399,7 @@ function twitter_test_connection(int $uid)
$status = [ $status = [
'code' => $response->getStatusCode(), 'code' => $response->getStatusCode(),
'reason' => $response->getReasonPhrase(), 'reason' => $response->getReasonPhrase(),
'content' => $response->getBody()->getContents() 'content' => $response->getBodyString()->getContents()
]; ];
DI::pConfig()->set(1, 'twitter', 'last_status', $status); DI::pConfig()->set(1, 'twitter', 'last_status', $status);
Logger::info('Test successful', ['uid' => $uid]); Logger::info('Test successful', ['uid' => $uid]);

View file

@ -113,7 +113,7 @@ class WebDav implements ICanWriteToStorage
$response = $this->client->request('propfind', $uri, $opts); $response = $this->client->request('propfind', $uri, $opts);
$responseDoc = new \DOMDocument(); $responseDoc = new \DOMDocument();
$responseDoc->loadXML($response->getBody()); $responseDoc->loadXML($response->getBodyString());
$responseDoc->formatOutput = true; $responseDoc->formatOutput = true;
$xpath = new \DOMXPath($responseDoc); $xpath = new \DOMXPath($responseDoc);
@ -205,7 +205,7 @@ class WebDav implements ICanWriteToStorage
throw new ReferenceStorageException(sprintf('Invalid reference %s', $reference)); throw new ReferenceStorageException(sprintf('Invalid reference %s', $reference));
} }
return $response->getBody(); return $response->getBodyString();
} }
/** /**

View file

@ -269,7 +269,7 @@ EOT;
Logger::debug('wppost: data: ' . $xml); Logger::debug('wppost: data: ' . $xml);
if ($wp_blog !== 'test') { if ($wp_blog !== 'test') {
$x = DI::httpClient()->post($wp_blog, $xml)->getBody(); $x = DI::httpClient()->post($wp_blog, $xml)->getBodyString();
} }
Logger::info('posted to wordpress: ' . (($x) ? $x : '')); Logger::info('posted to wordpress: ' . (($x) ? $x : ''));
} }