示例#1
0
 function rss2rdf($post_data)
 {
     // Function to convert RSS to RDF, some elements as tags will be missing
     //@FIXME: this solution is a bit hackish
     $post_data = str_replace('dc:date', 'dc_date', $post_data);
     // Parsing the new feeds to load in the triple store
     $xml = simplexml_load_string($post_data);
     if (count($xml) == 0) {
         return;
     }
     error_log("DEBUG: xml received from publisher: " . print_r($xml, 1), 0);
     foreach ($xml->item as $item) {
         $link = (string) $item->link;
         $date = (string) $item->dc_date;
         $description = (string) $item->description;
         $site = SMOBTools::host($link);
         $author = $site . "/me";
         $query = "INSERT INTO <{$link}> {\n            <{$site}> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://smob.me/ns#Hub> .\n            <{$link}> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://rdfs.org/sioc/types#MicroblogPost> .\n            <{$link}> <http://rdfs.org/sioc/ns#has_container> <{$site}> .\n            <{$link}> <http://rdfs.org/sioc/ns#has_creator> <{$author}> .\n            <{$link}> <http://xmlns.com/foaf/0.1/maker> <{$author}#id> .\n            <{$link}> <http://purl.org/dc/terms/created> \"{$date}\"^^<http://www.w3.org/2001/XMLSchema#dateTime> .\n            <{$link}> <http://purl.org/dc/terms/title> \"Update - {$date}\"^^<http://www.w3.org/2001/XMLSchema#string> .\n            <{$link}> <http://rdfs.org/sioc/ns#content> \"{$description}\"^^<http://www.w3.org/2001/XMLSchema#string> .\n            <{$link}#presence> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://online-presence.net/opo/ns#OnlinePresence> .\n            <{$link}#presence> <http://online-presence.net/opo/ns#declaredOn> <{$author}> .\n            <{$link}#presence> <http://online-presence.net/opo/ns#declaredBy> <{$author}#id> .\n            <{$link}#presence> <http://online-presence.net/opo/ns#StartTime> \"{$date}\"^^<http://www.w3.org/2001/XMLSchema#dateTime> .\n            <{$link}#presence> <http://online-presence.net/opo/ns#customMessage> <{$link}> . }";
         SMOBStore::query($query);
         error_log("DEBUG: Added the triples: {$query}", 0);
     }
 }
示例#2
0
文件: index.php 项目: anukat2015/smob
     $remote_user = $u;
     $local_user = SMOBTools::user_uri();
     $follow = "<{$remote_user}> sioc:follows <{$local_user}> . ";
     $local = "DELETE FROM <" . SMOB_ROOT . "data/followers> { {$follow} }";
     SMOBStore::query($local);
     error_log("DEBUG: Removed follower {$remote_user} with the query: {$local}", 0);
 } elseif ($t == 'following') {
     $remote_user = $u;
     $local_user = SMOBTools::user_uri();
     $follow = "<{$local_user}> sioc:follows <{$remote_user}> . ";
     $local = "DELETE FROM <" . SMOB_ROOT . "data/followings> { {$follow} }";
     SMOBStore::query($local);
     error_log("DEBUG: Removed following {$remote_user} with the query: {$local}", 0);
     // And ping to update the followers list remotely
     //$ping = str_replace("me","remove", $u)."/follower/$local_user";
     $ping = SMOBTools::host($u) . "/remove/follower/{$local_user}";
     error_log("DEBUG: Sent {$ping}", 0);
     $result = SMOBTools::do_curl($ping);
     error_log("DEBUG: Server answer: " . join(' ', $result), 0);
     // Unsubscribe to the Hub
     //@TODO: following Hub should be stored?,
     $remote_user_feed = $remote_user . FEED_URL_PATH;
     $xml = simplexml_load_file($remote_user_feed);
     if (count($xml) == 0) {
         return;
     }
     $link_attributes = $xml->channel->link->attributes();
     if ($link_attributes['rel'] == 'hub') {
         $hub_url = $link_attributes['href'];
     }
     $callback_url = urlencode(SMOB_ROOT . "callback");