Exemple #1
0
 function get_uris()
 {
     $uri = "http://api.sindice.com/v2/search?page=1&q=" . urlencode($this->item) . "&qt=term&format=json";
     $res = SMOBTools::do_curl($uri);
     $json = json_decode($res[1], true);
     foreach ($json['entries'] as $j) {
         $r[$j['title'][0]] = $j['link'];
     }
     return $r;
 }
Exemple #2
0
 function get_uris()
 {
     $uri = "http://lookup.dbpedia.org/api/search.asmx/KeywordSearch?QueryString=" . urlencode($this->item) . "&QueryClass=&MaxHits=10";
     $res = SMOBTools::do_curl($uri, null, null, 'GET');
     $xml = simplexml_load_string($res[0]);
     foreach ($xml->Result as $x) {
         // That shall work with an XML method
         $vars = get_object_vars($x);
         $r[$vars['Label']] = $vars['URI'];
     }
     return $r;
 }
Exemple #3
0
 function get_uris()
 {
     $uri = "http://ws.geonames.org/searchJSON?q=" . urlencode($this->item) . "&maxRows=10";
     $res = SMOBTools::do_curl($uri);
     $json = json_decode($res[1], true);
     foreach ($json['geonames'] as $j) {
         $uri = "http://sws.geonames.org/" . $j['geonameId'] . "/";
         $name = $j['name'] . '(' . $j['countryName'] . ')';
         $r[$name] = $uri;
     }
     return $r;
 }
Exemple #4
0
 public function getposts()
 {
     $url = 'http://twitter.com/statuses/home_timeline.json';
     $userpwd = $this->user . ':' . $this->pass;
     $res = SMOBTools::do_curl($url, '', $userpwd, 'GET');
     $tweets = json_decode($res[0]);
     foreach ($tweets as $tweet) {
         $id = $tweet->id;
         $username = $tweet->user->screen_name;
         $uri = "http://twitter.com/{$username}/status/{$id}";
         if (!SMOBStore::ask("<{$uri}> a sioct:MicroblogPost")) {
             echo "LOADING {$uri}<br/>";
             $this->load_tweet($tweet);
         }
     }
 }
Exemple #5
0
 function get_uri_if_found($uri)
 {
     list($resp, $status, $code) = SMOBTools::do_curl($uri);
     if ($code == 200) {
         return $uri;
     } else {
         if ($code == 404) {
             return "";
         } else {
             print "Error fetching {$uri}: ";
             if ($status) {
                 print $status;
             } else {
                 print $resp;
             }
             return "";
         }
     }
 }
Exemple #6
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");
         $feed = urlencode($remote_user_feed);
         $result = SMOBTools::do_curl($hub_url, $postfields = "hub.mode=unsubscribe&hub.verify=async&hub.callback={$callback_url}&hub.topic={$feed}");
         // all good -- anything in the 200 range
         if (substr($result[2], 0, 1) == "2") {
             error_log("DEBUG: Successfully unsubscribed to topic {$remote_user_feed} using hubsub {$hub_url}", 0);
         }
         error_log("DEBUG: Server answer: " . join(' ', $result), 0);
         //print "<a href='$remote_user'>$remote_user</a> was deleted from your following list and your subscription was removed";
         SMOBTemplate::footer();
     }
     header("Location: " . SMOB_ROOT . "{$t}s");
 } elseif ($t == 'rss_owner') {
     header("Content-type: text/xml");
     //$tweet = new SMOBFeed();
     //$tweet->rss();
     error_log("DEBUG: rssfilepath: " . FEED_FILE_PATH);
     if (!file_exists(FEED_FILE_PATH)) {
Exemple #7
0
 public function tweet()
 {
     $dest = 'http://twitter.com/statuses/update.xml';
     $postfields = 'status=' . urlencode($this->content) . '&source=smob';
     $userpwd = TWITTER_USER . ':' . TWITTER_PASS;
     SMOBTools::do_curl($dest, $postfields, $userpwd);
     print '<li>Notified on Twitter !</li>';
 }
Exemple #8
0
<?php

require_once dirname(__FILE__) . '/../lib/smob/SMOBTools.php';
$query = $_GET['query'];
$uri = "http://ws.geonames.org/searchJSON?q=" . urlencode($query) . "&maxRows=10";
$res = SMOBTools::do_curl($uri);
$json = json_decode($res[1], true);
foreach ($json['geonames'] as $j) {
    $uri = "http://sws.geonames.org/" . $j['geonameId'] . "/";
    $name = $j['name'] . ', ' . $j['countryName'] . ' (' . $j['fcodeName'] . ')';
    $suggestions .= "'{$name}',";
    $data .= "'{$uri}',";
}
$s = substr($suggestions, 0, -1);
$d = substr($data, 0, -1);
print "{ query:'{$query}',suggestions:[{$s}],data:[{$d}] }";