diff options
author | Mike Macgirvin <mike@macgirvin.com> | 2010-09-30 21:38:45 -0700 |
---|---|---|
committer | Mike Macgirvin <mike@macgirvin.com> | 2010-09-30 21:38:45 -0700 |
commit | 0d2650b29b92943a1570896491865c12fd28fda8 (patch) | |
tree | 5c9d30c87aeee1a92bc729ab9546c32033d11a43 /include/items.php | |
parent | 632c5570086bdfd8c8a311ccec44648697a8ef8b (diff) | |
download | volse-hubzilla-0d2650b29b92943a1570896491865c12fd28fda8.tar.gz volse-hubzilla-0d2650b29b92943a1570896491865c12fd28fda8.tar.bz2 volse-hubzilla-0d2650b29b92943a1570896491865c12fd28fda8.zip |
the rest of pubsubhubbub except for the UI that actually turns it on
Diffstat (limited to 'include/items.php')
-rw-r--r-- | include/items.php | 41 |
1 files changed, 40 insertions, 1 deletions
diff --git a/include/items.php b/include/items.php index 688ef244a..d726e961c 100644 --- a/include/items.php +++ b/include/items.php @@ -577,7 +577,7 @@ function dfrn_deliver($contact,$atom,$debugging = false) { } -function consume_feed($xml,$importer,$contact) { +function consume_feed($xml,$importer,$contact, &$hub) { require_once('simplepie/simplepie.inc'); @@ -593,6 +593,12 @@ function consume_feed($xml,$importer,$contact) { $photo_timestamp = ''; $photo_url = ''; + + $foundhub = $feed->get_link(0,'hub'); + + if(strlen($foundhub)) + $hub = $foundhub; + $rawtags = $feed->get_feed_tags( SIMPLEPIE_NAMESPACE_ATOM_10, 'author'); if($rawtags) { $elems = $rawtags[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]; @@ -808,4 +814,37 @@ function consume_feed($xml,$importer,$contact) { } } +} + + +function subscribe_to_hub($url,$importer,$contact) { + + if(is_array($importer)) { + $r = q("SELECT `nickname` FROM `user` WHERE `uid` = %d LIMIT 1", + intval($importer['uid']) + ); + } + if(! count($r)) + return; + + $params = array(); + + $push_url = get_config('system','url') . '/pubsub/' . $r[0]['nickname'] . '/' . $contact['id']; + + $verify_token = random_string(); + + $params['hub.mode'] = 'subscribe'; + $params['hub.callback'] = urlencode($push_url); + $params['hub.topic'] = urlencode($contact['poll']); + $params['hub.verify'] = 'async'; + $params['hub.verify_token'] = $verify_token; + + $r = q("UPDATE `contact` SET `hub-verify` = '%s' WHERE `id` = %d LIMIT 1", + dbesc($verify_token), + intval($contact['id']) + ); + + post_url($url,$params); + return; + }
\ No newline at end of file |