better twitter follow support
This commit is contained in:
parent
793967a1d3
commit
4c5e091b78
|
@ -227,16 +227,36 @@ function scrape_feed($url) {
|
||||||
if(! $dom)
|
if(! $dom)
|
||||||
return $ret;
|
return $ret;
|
||||||
|
|
||||||
|
|
||||||
|
$items = $dom->getElementsByTagName('img');
|
||||||
|
|
||||||
|
// get img elements (twitter)
|
||||||
|
|
||||||
|
if($items) {
|
||||||
|
foreach($items as $item) {
|
||||||
|
$x = $item->getAttribute('id');
|
||||||
|
if($x === 'profile-image') {
|
||||||
|
$ret['photo'] = $item->getAttribute('src');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$items = $dom->getElementsByTagName('link');
|
$items = $dom->getElementsByTagName('link');
|
||||||
|
|
||||||
// get Atom link elements
|
// get Atom/RSS link elements, take the first one of either.
|
||||||
|
|
||||||
foreach($items as $item) {
|
if($items) {
|
||||||
$x = $item->getAttribute('rel');
|
foreach($items as $item) {
|
||||||
if(($x === 'alternate') && ($item->getAttribute('type') === 'application/atom+xml'))
|
$x = $item->getAttribute('rel');
|
||||||
$ret['feed_atom'] = $item->getAttribute('href');
|
if(($x === 'alternate') && ($item->getAttribute('type') === 'application/atom+xml')) {
|
||||||
if(($x === 'alternate') && ($item->getAttribute('type') === 'application/rss+xml'))
|
if(! x($ret,'feed_atom'))
|
||||||
$ret['feed_rss'] = $item->getAttribute('href');
|
$ret['feed_atom'] = $item->getAttribute('href');
|
||||||
|
}
|
||||||
|
if(($x === 'alternate') && ($item->getAttribute('type') === 'application/rss+xml')) {
|
||||||
|
if(! x($ret,'feed_rss'))
|
||||||
|
$ret['feed_rss'] = $item->getAttribute('href');
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $ret;
|
return $ret;
|
||||||
|
|
|
@ -112,6 +112,8 @@ function follow_post(&$a) {
|
||||||
if(count($ret) && ($ret['feed_atom'] || $ret['feed_rss'])) {
|
if(count($ret) && ($ret['feed_atom'] || $ret['feed_rss'])) {
|
||||||
$poll = ((x($ret,'feed_atom')) ? unamp($ret['feed_atom']) : unamp($ret['feed_rss']));
|
$poll = ((x($ret,'feed_atom')) ? unamp($ret['feed_atom']) : unamp($ret['feed_rss']));
|
||||||
$vcard = array();
|
$vcard = array();
|
||||||
|
if(x($ret,'photo'))
|
||||||
|
$vcard['photo'] = $ret['photo'];
|
||||||
require_once('simplepie/simplepie.inc');
|
require_once('simplepie/simplepie.inc');
|
||||||
$feed = new SimplePie();
|
$feed = new SimplePie();
|
||||||
$xml = fetch_url($poll);
|
$xml = fetch_url($poll);
|
||||||
|
@ -120,7 +122,8 @@ function follow_post(&$a) {
|
||||||
|
|
||||||
$feed->init();
|
$feed->init();
|
||||||
|
|
||||||
$vcard['photo'] = $feed->get_image_url();
|
if(! x($vcard,'photo'))
|
||||||
|
$vcard['photo'] = $feed->get_image_url();
|
||||||
$author = $feed->get_author();
|
$author = $feed->get_author();
|
||||||
if($author) {
|
if($author) {
|
||||||
$vcard['fn'] = unxmlify(trim($author->get_name()));
|
$vcard['fn'] = unxmlify(trim($author->get_name()));
|
||||||
|
|
Loading…
Reference in a new issue