From 13fd713b66cdce186f30cb70bdcf237814f961b5 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Fri, 12 Jan 2024 01:16:01 -0500 Subject: [PATCH] [various] Rename ICanHandleHttpResponses->getBody to getBodyString - Depends on https://github.com/friendica/friendica/pull/13826 --- bluesky/bluesky.php | 14 +++++++------- discourse/discourse.php | 4 ++-- dwpost/dwpost.php | 2 +- ijpost/ijpost.php | 2 +- libertree/libertree.php | 2 +- ljpost/ljpost.php | 2 +- mailstream/mailstream.php | 2 +- mastodoncustomemojis/mastodoncustomemojis.php | 2 +- openstreetmap/openstreetmap.php | 2 +- tumblr/tumblr.php | 10 +++++----- twitter/twitter.php | 4 ++-- webdav_storage/src/WebDav.php | 4 ++-- wppost/wppost.php | 2 +- 13 files changed, 26 insertions(+), 26 deletions(-) diff --git a/bluesky/bluesky.php b/bluesky/bluesky.php index dac95437..a2c85ad3 100644 --- a/bluesky/bluesky.php +++ b/bluesky/bluesky.php @@ -1111,11 +1111,11 @@ function bluesky_process_post(stdClass $post, int $uid, int $post_reason, int $l $uri = bluesky_get_uri($post); if ($id = Post::selectFirst(['id'], ['uri' => $uri, 'uid' => $uid])) { - return $id['id']; + return $id['id']; } if ($id = Post::selectFirst(['id'], ['extid' => $uri, 'uid' => $uid])) { - return $id['id']; + return $id['id']; } Logger::debug('Importing post', ['uid' => $uid, 'indexedAt' => $post->indexedAt, 'uri' => $post->uri, 'cid' => $post->cid, 'root' => $post->record->reply->root ?? '']); @@ -1251,7 +1251,7 @@ function bluesky_get_text(stdClass $record, int $uri_id): string $url = DI::baseUrl() . '/search?tag=' . urlencode($feature->tag); $linktext = '#' . $feature->tag; break; - + default: Logger::notice('Unhandled feature type', ['type' => $feature->$type, 'feature' => $feature, 'record' => $record]); break; @@ -1736,13 +1736,13 @@ function bluesky_post(int $uid, string $url, string $params, array $headers): ?s } 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); return null; } 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 @@ -1767,9 +1767,9 @@ function bluesky_get(string $url, string $accept_content = HttpClientAccept::DEF } 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 json_decode($curlResult->getBody()); + return json_decode($curlResult->getBodyString()); } diff --git a/discourse/discourse.php b/discourse/discourse.php index 3d27c5b0..298b3f3e 100644 --- a/discourse/discourse.php +++ b/discourse/discourse.php @@ -126,7 +126,7 @@ function discourse_fetch_post($host, $topic, $pid) return false; } - $raw = $curlResult->getBody(); + $raw = $curlResult->getBodyString(); $data = json_decode($raw, true); $posts = $data['post_stream']['posts']; foreach($posts as $post) { @@ -162,7 +162,7 @@ function discourse_fetch_post_from_api(&$message, $post, $host) return false; } - $raw = $curlResult->getBody(); + $raw = $curlResult->getBodyString(); $data = json_decode($raw, true); if (empty($data)) { return false; diff --git a/dwpost/dwpost.php b/dwpost/dwpost.php index 6c1742e4..4ad5021f 100644 --- a/dwpost/dwpost.php +++ b/dwpost/dwpost.php @@ -192,7 +192,7 @@ EOT; Logger::debug('dwpost: data: ' . $xml); 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 : ''); diff --git a/ijpost/ijpost.php b/ijpost/ijpost.php index 55d3fb05..885bc289 100644 --- a/ijpost/ijpost.php +++ b/ijpost/ijpost.php @@ -186,7 +186,7 @@ EOT; Logger::debug('ijpost: data: ' . $xml); 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 : ''); } diff --git a/libertree/libertree.php b/libertree/libertree.php index c0f896c0..f69c0aab 100644 --- a/libertree/libertree.php +++ b/libertree/libertree.php @@ -201,7 +201,7 @@ function libertree_send(array &$b) // 'token' => $ltree_api_token ]; - $result = DI::httpClient()->post($ltree_blog, $params)->getBody(); + $result = DI::httpClient()->post($ltree_blog, $params)->getBodyString(); Logger::notice('libertree: ' . $result); } } diff --git a/ljpost/ljpost.php b/ljpost/ljpost.php index f6f2b79a..fac44767 100644 --- a/ljpost/ljpost.php +++ b/ljpost/ljpost.php @@ -207,7 +207,7 @@ EOT; Logger::debug('ljpost: data: ' . $xml); 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 : ''); diff --git a/mailstream/mailstream.php b/mailstream/mailstream.php index d76ccf86..968ee4c0 100644 --- a/mailstream/mailstream.php +++ b/mailstream/mailstream.php @@ -221,7 +221,7 @@ function mailstream_do_images(array &$item, array &$attachments) continue; } $attachments[$url] = [ - 'data' => $curlResult->getBody(), + 'data' => $curlResult->getBodyString(), 'guid' => hash('crc32', $url), 'filename' => basename($components['path']), 'type' => $curlResult->getContentType() diff --git a/mastodoncustomemojis/mastodoncustomemojis.php b/mastodoncustomemojis/mastodoncustomemojis.php index c84f1a4f..f67054a1 100644 --- a/mastodoncustomemojis/mastodoncustomemojis.php +++ b/mastodoncustomemojis/mastodoncustomemojis.php @@ -82,7 +82,7 @@ function mastodoncustomemojis_fetch_custom_emojis_for_url($api_base_url) $fetchResult = DI::httpClient()->fetchFull($api_url); 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)) { foreach ($emojis_array as $emoji) { diff --git a/openstreetmap/openstreetmap.php b/openstreetmap/openstreetmap.php index 3b7c4a58..ae22aff0 100644 --- a/openstreetmap/openstreetmap.php +++ b/openstreetmap/openstreetmap.php @@ -121,7 +121,7 @@ function openstreetmap_get_coordinates(array &$b) if (is_null($j)) { $curlResult = DI::httpClient()->get($nomserver . $args); if ($curlResult->isSuccess()) { - $j = json_decode($curlResult->getBody(), true); + $j = json_decode($curlResult->getBodyString(), true); DI::cache()->set($cachekey, $j, Duration::MONTH); } } diff --git a/tumblr/tumblr.php b/tumblr/tumblr.php index 4d5368b8..d6508ff8 100644 --- a/tumblr/tumblr.php +++ b/tumblr/tumblr.php @@ -1244,7 +1244,7 @@ function tumblr_get_contact_by_url(string $url, int $uid): ?array } catch (\Exception $e) { return null; } - $html = $curlResult->getBody(); + $html = $curlResult->getBodyString(); if (empty($html)) { return null; } @@ -1372,7 +1372,7 @@ function tumblr_delete(int $uid, string $url, array $parameters): stdClass */ function tumblr_format_result(ICanHandleHttpResponses $curlResult): stdClass { - $result = json_decode($curlResult->getBody()); + $result = json_decode($curlResult->getBodyString()); if (empty($result) || empty($result->meta)) { $result = 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); 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 ''; } - $result = json_decode($curlResult->getBody()); + $result = json_decode($curlResult->getBodyString()); if (empty($result)) { Logger::info('Invalid result when updating token', ['uid' => $uid]); return ''; @@ -1479,7 +1479,7 @@ function tumblr_exchange_token(int $uid): stdClass ]); $response = $client->post('oauth2/exchange', ['auth' => 'oauth']); - return json_decode($response->getBody()->getContents()); + return json_decode($response->getBodyString()->getContents()); } catch (RequestException $exception) { Logger::notice('Exchange failed', ['code' => $exception->getCode(), 'message' => $exception->getMessage()]); return new stdClass; diff --git a/twitter/twitter.php b/twitter/twitter.php index b01345b7..8c906daf 100644 --- a/twitter/twitter.php +++ b/twitter/twitter.php @@ -362,7 +362,7 @@ function twitter_post(int $uid, string $url, string $type, array $data): stdClas ]); $response = $client->post($url, ['auth' => 'oauth', $type => $data]); - $body = $response->getBody()->getContents(); + $body = $response->getBodyString()->getContents(); $status = [ 'code' => $response->getStatusCode(), @@ -399,7 +399,7 @@ function twitter_test_connection(int $uid) $status = [ 'code' => $response->getStatusCode(), 'reason' => $response->getReasonPhrase(), - 'content' => $response->getBody()->getContents() + 'content' => $response->getBodyString()->getContents() ]; DI::pConfig()->set(1, 'twitter', 'last_status', $status); Logger::info('Test successful', ['uid' => $uid]); diff --git a/webdav_storage/src/WebDav.php b/webdav_storage/src/WebDav.php index de9fc476..ddf2dae0 100644 --- a/webdav_storage/src/WebDav.php +++ b/webdav_storage/src/WebDav.php @@ -113,7 +113,7 @@ class WebDav implements ICanWriteToStorage $response = $this->client->request('propfind', $uri, $opts); $responseDoc = new \DOMDocument(); - $responseDoc->loadXML($response->getBody()); + $responseDoc->loadXML($response->getBodyString()); $responseDoc->formatOutput = true; $xpath = new \DOMXPath($responseDoc); @@ -205,7 +205,7 @@ class WebDav implements ICanWriteToStorage throw new ReferenceStorageException(sprintf('Invalid reference %s', $reference)); } - return $response->getBody(); + return $response->getBodyString(); } /** diff --git a/wppost/wppost.php b/wppost/wppost.php index 0405f78a..e27079aa 100644 --- a/wppost/wppost.php +++ b/wppost/wppost.php @@ -269,7 +269,7 @@ EOT; Logger::debug('wppost: data: ' . $xml); 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 : '')); }