From c5554536a29d40e5dfe11ca56f8d07b77c7d24ae Mon Sep 17 00:00:00 2001 From: emkael Date: Fri, 2 Apr 2021 02:40:03 +0200 Subject: Adjustments to FB date parsing --- providers/Facebook.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'providers/Facebook.php') diff --git a/providers/Facebook.php b/providers/Facebook.php index b3f2015..d5233c3 100644 --- a/providers/Facebook.php +++ b/providers/Facebook.php @@ -20,7 +20,7 @@ class Facebook extends \Providers\HtmlFeed { } protected function __getUserAgent() { - return 'curl/7.72.0'; + return 'Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.51 Safari/537.36'; } protected function _getCachePath() { @@ -36,12 +36,16 @@ class Facebook extends \Providers\HtmlFeed { $string = str_replace("\xc2\xa0", ' ', $origString); $string = str_replace(' godzinie ', ' ', $string); $string = str_replace(' o ', ', ', $string); - $string = str_replace('godz.', 'hours ago', $string); $string = str_replace('Wczoraj', 'Yesterday', $string); + $string = str_replace('Dzisiaj', '', $string); + $string = str_replace('godz.', 'hours ago', $string); + $string = str_replace('min', 'minutes ago', $string); + $string = str_replace('Przed chwilą', 'now', $string); $string = str_replace(['stycznia', 'lutego', 'marca', 'kwietnia', 'maja', 'czerwca', 'lipca', 'sierpnia', 'września', 'października', 'listopada', 'grudnia'], ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'], $string); $time = strtotime($string); if (!$time) { - throw new Exception('Cannot parse date string: ' . $origString); + var_dump(bin2hex($origString)); + throw new \Exception('Cannot parse date string: ' . $origString); } return $string; } -- cgit v1.2.3