1
1
Fork 0

zot scraper

This commit is contained in:
Friendika 2011-07-11 18:28:13 -07:00
parent 2a65d01ce2
commit 180c15cdf8
2 changed files with 25 additions and 1 deletions

View file

@ -89,6 +89,7 @@ define ( 'PAGE_FREELOVE', 3 );
* Network and protocol family types
*/
define ( 'NETWORK_ZOT', 'zot!'); // Zot!
define ( 'NETWORK_DFRN', 'dfrn'); // Friendika, Mistpark, other DFRN implementations
define ( 'NETWORK_OSTATUS', 'stat'); // status.net, identi.ca, GNU-social, other OStatus implementations
define ( 'NETWORK_FEED', 'feed'); // RSS/Atom feeds with no known "post/notify" protocol
@ -117,6 +118,7 @@ define ( 'NOTIFY_MAIL', 0x0010 );
* various namespaces we may need to parse
*/
define ( 'NAMESPACE_ZOT', 'http://purl.org/macgirvin/zot' );
define ( 'NAMESPACE_DFRN' , 'http://purl.org/macgirvin/dfrn/1.0' );
define ( 'NAMESPACE_THREAD' , 'http://purl.org/syndication/thread/1.0' );
define ( 'NAMESPACE_TOMB' , 'http://purl.org/atompub/tombstones/1.0' );

View file

@ -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->name,
'nick' => $j->username,
'photo' => $j->photo
);
$profile = $j->url;
$notify = $j->post;
$key = $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;
@ -549,6 +570,7 @@ function probe_url($url) {
$result['priority'] = $priority;
$result['network'] = $network;
$result['alias'] = $alias;
$result['key'] = $key;
logger('probe_url: ' . print_r($result,true), LOGGER_DEBUG);