[FacebookBridge] Fix permalink issue (#1358)

Facebook has changed their strategy regarding permalinks, which
now include lots of unnecessary target data. Fortunately it also
contains the unique story id which we can utilize as URI.
This commit is contained in:
LogMANOriginal 2019-12-01 13:24:11 +01:00 committed by GitHub
parent 375831f516
commit df9f7eb778
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -701,9 +701,16 @@ EOD;
$uri = $post->find('abbr')[0]->parent()->getAttribute('href');
if (false !== strpos($uri, '?')) {
// Extract fbid and patch link
if (strpos($uri, '?') !== false) {
$query = substr($uri, strpos($uri, '?') + 1);
parse_str($query, $query_params);
if (isset($query_params['story_fbid'])) {
$uri = self::URI . $query_params['story_fbid'];
} else {
$uri = substr($uri, 0, strpos($uri, '?'));
}
}
//Build and add final item
$item['uri'] = htmlspecialchars_decode($uri, ENT_QUOTES);