]> git.mxchange.org Git - friendica.git/blobdiff - src/Util/ParseUrl.php
Make API testable & move PhotoAlbum tests to new destination
[friendica.git] / src / Util / ParseUrl.php
index 915a143a0473b87cb2f0de059ed0d84b13e2ebc2..6c3c4a0259e80873e1130d0b243531097f9fa3c1 100644 (file)
@@ -30,6 +30,7 @@ use Friendica\Database\Database;
 use Friendica\Database\DBA;
 use Friendica\DI;
 use Friendica\Network\HTTPException;
+use Friendica\Network\HTTPClient\Client\HttpClientOptions;
 
 /**
  * Get information about a given URL
@@ -58,7 +59,7 @@ class ParseUrl
         */
        public static function getContentType(string $url)
        {
-               $curlResult = DI::httpRequest()->head($url);
+               $curlResult = DI::httpClient()->head($url);
                if (!$curlResult->isSuccess()) {
                        return [];
                }
@@ -213,7 +214,7 @@ class ParseUrl
                        return $siteinfo;
                }
 
-               $curlResult = DI::httpRequest()->get($url, ['content_length' => 1000000]);
+               $curlResult = DI::httpClient()->get($url, [HttpClientOptions::CONTENT_LENGTH => 1000000]);
                if (!$curlResult->isSuccess() || empty($curlResult->getBody())) {
                        return $siteinfo;
                }
@@ -1115,7 +1116,11 @@ class ParseUrl
                }
 
                $content = JsonLD::fetchElement($jsonld, 'image', 'url', '@type', 'ImageObject');
-               if (!empty($content)) {
+               if (!empty($content) && !is_string($content)) {
+                       Logger::notice('Unexpected return value for the author image', ['content' => $content]);
+               }
+
+               if (!empty($content) && is_string($content)) {
                        $jsonldinfo['author_img'] = trim($content);
                }