diff options
author | Mike Macgirvin <mike@macgirvin.com> | 2010-10-25 21:52:30 -0700 |
---|---|---|
committer | Mike Macgirvin <mike@macgirvin.com> | 2010-10-25 21:52:30 -0700 |
commit | c16f314ec348205f4741e0171335168720e652d2 (patch) | |
tree | 008aaaf38da2b478eca0a91a0cf4de7bb08dd26f /include/Scrape.php | |
parent | 1335ef759522ef9f877c8e8fd806cf9bba36297d (diff) | |
download | volse-hubzilla-c16f314ec348205f4741e0171335168720e652d2.tar.gz volse-hubzilla-c16f314ec348205f4741e0171335168720e652d2.tar.bz2 volse-hubzilla-c16f314ec348205f4741e0171335168720e652d2.zip |
two-way subscriptions working with federated social accounts
Diffstat (limited to 'include/Scrape.php')
-rw-r--r-- | include/Scrape.php | 48 |
1 files changed, 38 insertions, 10 deletions
diff --git a/include/Scrape.php b/include/Scrape.php index 0272dde12..10ec54d13 100644 --- a/include/Scrape.php +++ b/include/Scrape.php @@ -2,15 +2,6 @@ require_once('library/HTML5/Parser.php'); -if(! function_exists('attribute_contains')) { -function attribute_contains($attr,$s) { - $a = explode(' ', $attr); - if(count($a) && in_array($s,$a)) - return true; - return false; -}} - - if(! function_exists('scrape_dfrn')) { function scrape_dfrn($url) { @@ -53,7 +44,7 @@ function scrape_dfrn($url) { $ret['photo'] = $x->getAttribute('src'); if(attribute_contains($x->getAttribute('class'),'key')) $ret['key'] = $x->textContent; - } + } } } @@ -107,3 +98,40 @@ function scrape_meta($url) { return $ret; }} + + +if(! function_exists('scrape_vcard')) { +function scrape_vcard($url) { + + $ret = array(); + $s = fetch_url($url); + + if(! $s) + return $ret; + + $dom = HTML5_Parser::parse($s); + + if(! $dom) + return $ret; + + // Pull out hCard profile elements + + $items = $dom->getElementsByTagName('*'); + foreach($items as $item) { + if(attribute_contains($item->getAttribute('class'), 'vcard')) { + $level2 = $item->getElementsByTagName('*'); + foreach($level2 as $x) { + if(attribute_contains($x->getAttribute('class'),'fn')) + $ret['fn'] = $x->textContent; + if((attribute_contains($x->getAttribute('class'),'photo')) + || (attribute_contains($x->getAttribute('class'),'avatar'))) + $ret['photo'] = $x->getAttribute('src'); + if((attribute_contains($x->getAttribute('class'),'nickname')) + || (attribute_contains($x->getAttribute('class'),'uid'))) + $ret['nick'] = $x->textContent; + } + } + } + + return $ret; +}} |