Remove tracking codes from Facebook posts
This commit is contained in:
parent
53d2fbe3a5
commit
723bd1150a
1 changed files with 22 additions and 0 deletions
|
@ -364,6 +364,26 @@ class FacebookBridge extends BridgeAbstract {
|
||||||
}, $content);
|
}, $content);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove Facebook's tracking code
|
||||||
|
*/
|
||||||
|
private function remove_tracking_codes($content){
|
||||||
|
return preg_replace_callback('/ href=\"([^"]+)\"/i', function($matches){
|
||||||
|
if(is_array($matches) && count($matches) > 1) {
|
||||||
|
|
||||||
|
$link = $matches[1];
|
||||||
|
|
||||||
|
if(strpos($link, 'facebook.com') !== false) {
|
||||||
|
if(strpos($link, '?') !== false) {
|
||||||
|
$link = substr($link, 0, strpos($link, '?'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ' href="' . $link . '"';
|
||||||
|
|
||||||
|
}
|
||||||
|
}, $content);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert textual representation of emoticons back to ASCII emoticons.
|
* Convert textual representation of emoticons back to ASCII emoticons.
|
||||||
* i.e. "<i><u>smile emoticon</u></i>" => ":)"
|
* i.e. "<i><u>smile emoticon</u></i>" => ":)"
|
||||||
|
@ -610,6 +630,8 @@ EOD;
|
||||||
// Restore links in the content before adding to the item
|
// Restore links in the content before adding to the item
|
||||||
$content = defaultLinkTo($content, self::URI);
|
$content = defaultLinkTo($content, self::URI);
|
||||||
|
|
||||||
|
$content = $this->remove_tracking_codes($content);
|
||||||
|
|
||||||
// Retrieve date of the post
|
// Retrieve date of the post
|
||||||
$date = $post->find('abbr')[0];
|
$date = $post->find('abbr')[0];
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue