X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=include%2FScrape.php;h=6726d0b1518d815b5ebc05bca6c5bc88ba6d3f46;hb=abc01cad20f599a205e5c2534936092f6820e702;hp=1a9c03c8eccb99adc362b0a8a674552e8906b19a;hpb=44a22c29155fa3beeed7cd5d0add30818e409891;p=friendica.git diff --git a/include/Scrape.php b/include/Scrape.php index 1a9c03c8ec..6726d0b151 100644 --- a/include/Scrape.php +++ b/include/Scrape.php @@ -300,6 +300,8 @@ function probe_url($url) { if(count($links)) { logger('probe_url: found lrdd links: ' . print_r($links,true), LOGGER_DATA); foreach($links as $link) { + if($link['@attributes']['rel'] === NAMESPACE_ZOT) + $zot = unamp($link['@attributes']['href']); if($link['@attributes']['rel'] === NAMESPACE_DFRN) $dfrn = unamp($link['@attributes']['href']); if($link['@attributes']['rel'] === 'salmon') @@ -379,6 +381,25 @@ function probe_url($url) { } } + if(strlen($zot)) { + $s = fetch_url($zot); + if($s) { + $j = json_decode($s); + if($j) { + $network = NETWORK_ZOT; + $vcard = array( + 'fn' => $j->fullname, + 'nick' => $j->nickname, + 'photo' => $j->photo + ); + $profile = $j->url; + $notify = $j->post; + $pubkey = $j->pubkey; + $poll = 'N/A'; + } + } + } + if(strlen($dfrn)) { $ret = scrape_dfrn($dfrn); if(is_array($ret) && x($ret,'dfrn-request')) { @@ -390,7 +411,7 @@ function probe_url($url) { } } - if($network !== NETWORK_DFRN && $network !== NETWORK_MAIL) { + if($network !== NETWORK_ZOT && $network !== NETWORK_DFRN && $network !== NETWORK_MAIL) { $network = NETWORK_OSTATUS; $priority = 0; @@ -423,7 +444,7 @@ function probe_url($url) { $poll = $tapi . '?user_id=' . $tid; else $poll = $tapi . '?screen_name=' . $tid; - $profile = 'http://twitter.com/!#/' . $tid; + $profile = 'http://twitter.com/#!/' . $tid; } if(! x($vcard,'fn')) @@ -442,13 +463,20 @@ function probe_url($url) { if(x($feedret,'photo')) $vcard['photo'] = $feedret['photo']; - require_once('simplepie/simplepie.inc'); + 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(); @@ -460,6 +488,14 @@ function probe_url($url) { if(strpos($vcard['fn'],'@') !== false) $vcard['fn'] = substr($vcard['fn'],0,strpos($vcard['fn'],'@')); $email = unxmlify($author->get_email()); + 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']; + } + } } else { $item = $feed->get_item(0); @@ -478,6 +514,14 @@ function probe_url($url) { if($rawmedia && $rawmedia[0]['attribs']['']['url']) $vcard['photo'] = unxmlify($rawmedia[0]['attribs']['']['url']); } + if(! $vcard['photo']) { + $rawtags = $item->get_item_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']; + } + } } } if((! $vcard['photo']) && strlen($email)) @@ -526,6 +570,7 @@ function probe_url($url) { $result['priority'] = $priority; $result['network'] = $network; $result['alias'] = $alias; + $result['pubkey'] = $pubkey; logger('probe_url: ' . print_r($result,true), LOGGER_DEBUG);