[TwitterBridge] clean links

This commit is contained in:
Mitsukarenai 2014-05-28 17:10:49 +02:00
parent 0874e13824
commit 0c7729e783

View file

@ -37,6 +37,18 @@ class TwitterBridge extends BridgeAbstract{
$item->id = $tweet->getAttribute('data-tweet-id'); // get TweetID $item->id = $tweet->getAttribute('data-tweet-id'); // get TweetID
$item->uri = 'https://twitter.com'.$tweet->find('a.js-permalink', 0)->getAttribute('href'); // get tweet link $item->uri = 'https://twitter.com'.$tweet->find('a.js-permalink', 0)->getAttribute('href'); // get tweet link
$item->timestamp = $tweet->find('span.js-short-timestamp', 0)->getAttribute('data-time'); // extract tweet timestamp $item->timestamp = $tweet->find('span.js-short-timestamp', 0)->getAttribute('data-time'); // extract tweet timestamp
// processing content links
foreach($tweet->find('a') as $link) {
if($link->hasAttribute('data-expanded-url') ) {
$link->href = $link->getAttribute('data-expanded-url');
}
$link->removeAttribute('data-expanded-url');
$link->removeAttribute('data-query-source');
$link->removeAttribute('rel');
$link->removeAttribute('class');
$link->removeAttribute('target');
$link->removeAttribute('title');
}
$item->content = str_replace('href="/', 'href="https://twitter.com/', strip_tags($tweet->find('p.js-tweet-text', 0)->innertext, '<a>')); // extract tweet text $item->content = str_replace('href="/', 'href="https://twitter.com/', strip_tags($tweet->find('p.js-tweet-text', 0)->innertext, '<a>')); // extract tweet text
$item->title = $item->fullname . ' (@'. $item->username . ') | ' . $item->content; $item->title = $item->fullname . ' (@'. $item->username . ') | ' . $item->content;
$this->items[] = $item; $this->items[] = $item;