- $ret = scrape_feed($url);
- logger('probe_url: scrape_feed returns: ' . print_r($ret,true), LOGGER_DATA);
- if(count($ret) && ($ret['feed_atom'] || $ret['feed_rss'])) {
- $poll = ((x($ret,'feed_atom')) ? unamp($ret['feed_atom']) : unamp($ret['feed_rss']));
- $vcard = array();
- if(x($ret,'photo'))
- $vcard['photo'] = $ret['photo'];
- require_once('simplepie/simplepie.inc');
- $feed = new SimplePie();
- $xml = fetch_url($poll);
-
- $feed->set_raw_data($xml);
-
- $feed->init();
-
- if(! x($vcard,'photo'))
- $vcard['photo'] = $feed->get_image_url();
- $author = $feed->get_author();
- if($author) {
- $vcard['fn'] = unxmlify(trim($author->get_name()));
- if(! $vcard['fn'])
- $vcard['fn'] = trim(unxmlify($author->get_email()));
- if(strpos($vcard['fn'],'@') !== false)
- $vcard['fn'] = substr($vcard['fn'],0,strpos($vcard['fn'],'@'));
- $vcard['nick'] = strtolower(notags(unxmlify($vcard['fn'])));
- if(strpos($vcard['nick'],' '))
- $vcard['nick'] = trim(substr($vcard['nick'],0,strpos($vcard['nick'],' ')));
- $email = unxmlify($author->get_email());
+ if($twitter || ! $poll)
+ $check_feed = true;
+ if((! isset($vcard)) || (! x($vcard,'fn')) || (! $profile))
+ $check_feed = true;
+ if(($at_addr) && (! count($links)))
+ $check_feed = false;
+
+ if($check_feed) {
+
+ $feedret = scrape_feed(($poll) ? $poll : $url);
+ logger('probe_url: scrape_feed returns: ' . print_r($feedret,true), LOGGER_DATA);
+ if(count($feedret) && ($feedret['feed_atom'] || $feedret['feed_rss'])) {
+ $poll = ((x($feedret,'feed_atom')) ? unamp($feedret['feed_atom']) : unamp($feedret['feed_rss']));
+ if(! x($vcard))
+ $vcard = array();
+ }
+
+ if(x($feedret,'photo') && (! x($vcard,'photo')))
+ $vcard['photo'] = $feedret['photo'];
+ require_once('library/simplepie/simplepie.inc');
+ $feed = new SimplePie();
+ $xml = fetch_url($poll);
+
+ logger('probe_url: fetch feed: ' . $poll . ' returns: ' . $xml, LOGGER_DATA);
+ $a = get_app();
+
+ logger('probe_url: scrape_feed: headers: ' . $a->get_curl_headers(), $LOGGER_DATA);
+
+ $feed->set_raw_data($xml);
+
+ $feed->init();
+ if($feed->error())
+ logger('probe_url: scrape_feed: Error parsing XML: ' . $feed->error());
+
+
+ if(! x($vcard,'photo'))
+ $vcard['photo'] = $feed->get_image_url();
+ $author = $feed->get_author();
+
+ if($author) {
+ $vcard['fn'] = unxmlify(trim($author->get_name()));
+ if(! $vcard['fn'])
+ $vcard['fn'] = trim(unxmlify($author->get_email()));
+ if(strpos($vcard['fn'],'@') !== false)
+ $vcard['fn'] = substr($vcard['fn'],0,strpos($vcard['fn'],'@'));
+ $email = unxmlify($author->get_email());
+ if(! $profile && $author->get_link())
+ $profile = trim(unxmlify($author->get_link()));
+ if(! $vcard['photo']) {
+ $rawtags = $feed->get_feed_tags( SIMPLEPIE_NAMESPACE_ATOM_10, 'author');
+ if($rawtags) {
+ $elems = $rawtags[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10];
+ if((x($elems,'link')) && ($elems['link'][0]['attribs']['']['rel'] === 'photo'))
+ $vcard['photo'] = $elems['link'][0]['attribs']['']['href'];
+ }