X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2FScrape.php;h=52405ae2dd556e5ee1ce434acfbca1b75f15500a;hb=808b886a3e18b07c63171c4833334e2cf77ddf71;hp=58468a40d021ab6de2f008bd704cffbbe1233cfa;hpb=9d2afc2d3c12f6b70eae11487e491e2d8604ed60;p=friendica.git diff --git a/include/Scrape.php b/include/Scrape.php old mode 100644 new mode 100755 index 58468a40d0..52405ae2dd --- a/include/Scrape.php +++ b/include/Scrape.php @@ -30,8 +30,11 @@ function scrape_dfrn($url) { } } - - $dom = HTML5_Parser::parse($s); + try { + $dom = HTML5_Parser::parse($s); + } catch (DOMException $e) { + logger('scrape_dfrn: parse error: ' . $e); + } if(! $dom) return $ret; @@ -132,9 +135,11 @@ function scrape_meta($url) { } } - - - $dom = HTML5_Parser::parse($s); + try { + $dom = HTML5_Parser::parse($s); + } catch (DOMException $e) { + logger('scrape_meta: parse error: ' . $e); + } if(! $dom) return $ret; @@ -177,7 +182,11 @@ function scrape_vcard($url) { } } - $dom = HTML5_Parser::parse($s); + try { + $dom = HTML5_Parser::parse($s); + } catch (DOMException $e) { + logger('scrape_vcard: parse error: ' . $e); + } if(! $dom) return $ret; @@ -243,26 +252,16 @@ function scrape_feed($url) { } } - $dom = HTML5_Parser::parse($s); + try { + $dom = HTML5_Parser::parse($s); + } catch (DOMException $e) { + logger('scrape_feed: parse error: ' . $e); + } if(! $dom) 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'); - } - } - } - - $head = $dom->getElementsByTagName('base'); if($head) { foreach($head as $head0) { @@ -315,7 +314,7 @@ function scrape_feed($url) { * * PROBE_DIASPORA has a bias towards returning Diaspora information * while PROBE_NORMAL has a bias towards dfrn/zot - in the case where - * an address (such as a Friendika address) supports more than one type + * an address (such as a Friendica address) supports more than one type * of network. * */ @@ -370,6 +369,8 @@ function probe_url($url, $mode = PROBE_NORMAL) { $hcard = unamp($link['@attributes']['href']); if($link['@attributes']['rel'] === 'http://webfinger.net/rel/profile-page') $profile = unamp($link['@attributes']['href']); + if($link['@attributes']['rel'] === 'http://portablecontacts.net/spec/1.0') + $poco = unamp($link['@attributes']['href']); if($link['@attributes']['rel'] === 'http://joindiaspora.com/seed_location') { $diaspora_base = unamp($link['@attributes']['href']); $diaspora = true; @@ -496,8 +497,10 @@ function probe_url($url, $mode = PROBE_NORMAL) { } if($diaspora && $diaspora_base && $diaspora_guid) { - if($mode == PROBE_DIASPORA || ! $notify) + if($mode == PROBE_DIASPORA || ! $notify) { $notify = $diaspora_base . 'receive/users/' . $diaspora_guid; + $batch = $diaspora_base . 'receive/public' ; + } if(strpos($url,'@')) $addr = str_replace('acct:', '', $url); } @@ -532,6 +535,9 @@ function probe_url($url, $mode = PROBE_NORMAL) { else $poll = $tapi . '?screen_name=' . $tid; $profile = 'http://twitter.com/#!/' . $tid; + $vcard['photo'] = 'https://api.twitter.com/1/users/profile_image/' . $tid; + $vcard['nick'] = $tid; + $vcard['fn'] = $tid . '@twitter'; } if(! x($vcard,'fn')) @@ -542,7 +548,7 @@ function probe_url($url, $mode = PROBE_NORMAL) { if($twitter || ! $poll) $check_feed = true; - if((! isset($vcard)) || (! $profile)) + if((! isset($vcard)) || (! x($vcard,'fn')) || (! $profile)) $check_feed = true; if(($at_addr) && (! count($links))) $check_feed = false; @@ -675,10 +681,12 @@ function probe_url($url, $mode = PROBE_NORMAL) { $result['nick'] = $vcard['nick']; $result['url'] = $profile; $result['addr'] = $addr; + $result['batch'] = $batch; $result['notify'] = $notify; $result['poll'] = $poll; $result['request'] = $request; $result['confirm'] = $confirm; + $result['poco'] = $poco; $result['photo'] = $vcard['photo']; $result['priority'] = $priority; $result['network'] = $network;