- $a = get_app();
-
- logger('probe_url: scrape_feed: headers: ' . $a->get_curl_headers(), LOGGER_DATA);
-
- // Don't try and parse an empty string
- $feed->set_raw_data(($xml) ? $xml : '<?xml version="1.0" encoding="utf-8" ?><xml></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'];
- }
- }
- // Fetch fullname via poco:displayName
- $pocotags = $feed->get_feed_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'author');
- if ($pocotags) {
- $elems = $pocotags[0]['child']['http://portablecontacts.net/spec/1.0'];
- if (isset($elems["displayName"]))
- $vcard['fn'] = $elems["displayName"][0]["data"];
- if (isset($elems["preferredUsername"]))
- $vcard['nick'] = $elems["preferredUsername"][0]["data"];
+
+ if ($xml == "") {
+ logger("scrape_feed: XML is empty for feed ".$poll);
+ $network = NETWORK_PHANTOM;
+ } else {
+ $data = feed_import($xml,$dummy1,$dummy2, $dummy3, true);
+
+ if (!is_array($data)) {
+ logger("scrape_feed: This doesn't seem to be a feed: ".$poll);
+ $network = NETWORK_PHANTOM;
+ } else {
+ if (($vcard["photo"] == "") AND ($data["header"]["author-avatar"] != ""))
+ $vcard["photo"] = $data["header"]["author-avatar"];
+
+ if (($vcard["fn"] == "") AND ($data["header"]["author-name"] != ""))
+ $vcard["fn"] = $data["header"]["author-name"];
+
+ if (($vcard["nick"] == "") AND ($data["header"]["author-nick"] != ""))
+ $vcard["nick"] = $data["header"]["author-nick"];
+
+ if ($network == NETWORK_OSTATUS) {
+ if ($data["header"]["author-id"] != "")
+ $alias = $data["header"]["author-id"];
+
+ if ($data["header"]["author-link"] != "")
+ $profile = $data["header"]["author-link"];
+
+ } elseif(!$profile AND ($data["header"]["author-link"] != "") AND !in_array($network, array("", NETWORK_FEED)))
+ $profile = $data["header"]["author-link"];