Browse Source

[Facebook] make guids really permanent

Some facebook tracking query parameter was getting inside the <link>
and <guid> tags. This commit strips them off so that a feed reader
won't think there are always new posts.
boyska 5 years ago
parent
commit
3821ca9737
1 changed files with 10 additions and 2 deletions
  1. 10 2
      bridges/FacebookBridge.php

+ 10 - 2
bridges/FacebookBridge.php

@@ -165,6 +165,14 @@ class FacebookBridge extends BridgeAbstract {
 		return htmlspecialchars_decode($ogtitle->content, ENT_QUOTES);
 
 	}
+    private function uri_strip_args($uri) {
+        $clean = strtok($uri, '?');
+        if($clean === FALSE) {
+            return $uri;
+        } else {
+            return $clean;
+        }
+    }
 
 	private function extractGroupURI($post) {
 
@@ -175,7 +183,7 @@ class FacebookBridge extends BridgeAbstract {
 
 			// Find the one that is a permalink
 			if(strpos($anchor->href, 'permalink') !== false) {
-				return $anchor->href;
+				return $this->uri_strip_args($anchor->href);
 			}
 
 		}
@@ -539,7 +547,7 @@ EOD;
 						$uri = self::URI . $post->find('abbr')[0]->parent()->getAttribute('href');
 
 						//Build and add final item
-						$item['uri'] = htmlspecialchars_decode($uri);
+						$item['uri'] = $this->uri_strip_args(htmlspecialchars_decode($uri));
 						$item['content'] = htmlspecialchars_decode($content);
 						$item['title'] = $title;
 						$item['author'] = $author;