]> git.mxchange.org Git - friendica.git/blobdiff - src/Util/ParseUrl.php
Fixed max value check, improved request value fetching
[friendica.git] / src / Util / ParseUrl.php
index 03cfd7d7611cf338f71f375763be4dcc28b3fb20..04afc927ba6cec4229c8167a6bcafe66e4c317d9 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * @copyright Copyright (C) 2010-2021, the Friendica project
+ * @copyright Copyright (C) 2010-2022, the Friendica project
  *
  * @license GNU AGPL version 3 or any later version
  *
@@ -216,6 +216,7 @@ class ParseUrl
 
                $curlResult = DI::httpClient()->get($url, [HttpClientOptions::CONTENT_LENGTH => 1000000]);
                if (!$curlResult->isSuccess() || empty($curlResult->getBody())) {
+                       Logger::info('Empty body or error when fetching', ['url' => $url, 'success' => $curlResult->isSuccess(), 'code' => $curlResult->getReturnCode()]);
                        return $siteinfo;
                }
 
@@ -451,6 +452,12 @@ class ParseUrl
                                        case 'og:site_name':
                                                $siteinfo['publisher_name'] = trim($meta_tag['content']);
                                                break;
+                                       case 'og:locale':
+                                               $siteinfo['language'] = trim($meta_tag['content']);
+                                               break;
+                                       case 'og:type':
+                                               $siteinfo['pagetype'] = trim($meta_tag['content']);
+                                               break;
                                        case 'twitter:description':
                                                $siteinfo['text'] = trim($meta_tag['content']);
                                                break;
@@ -521,7 +528,7 @@ class ParseUrl
         *
         * @param string $page_url
         * @param array $siteinfo
-        * @return void
+        * @return array
         */
        private static function checkMedia(string $page_url, array $siteinfo) : array
        {
@@ -967,6 +974,16 @@ class ParseUrl
                        }
                }
 
+               $content = JsonLD::fetchElement($jsonld, 'datePublished');
+               if (!empty($content) && is_string($content)) {
+                       $jsonldinfo['published'] = DateTimeFormat::utc($content);
+               }
+
+               $content = JsonLD::fetchElement($jsonld, 'dateModified');
+               if (!empty($content) && is_string($content)) {
+                       $jsonldinfo['modified'] = DateTimeFormat::utc($content);
+               }
+
                $jsonldinfo = self::parseJsonLdAuthor($jsonldinfo, $jsonld);
 
                Logger::info('Fetched article information', ['url' => $siteinfo['url'], 'fetched' => $jsonldinfo]);