Exemple #1
0
$map_prefix_ns["foaf"] = "http://xmlns.com/foaf/0.1/";
$map_prefix_ns["rdfs"] = "http://www.w3.org/2000/01/rdf-schema#";
$map_prefix_ns["dc"] = "http://purl.org/dc/elements/1.1/";
$map_prefix_ns["rss"] = "http://purl.org/rss/1.0/";
$rdf = new RdfStream();
$rdf->begin($map_prefix_ns, $xmlbase, $prop_ns);
// content
$rowid = 1;
foreach ($items as $item) {
    //print_r($item);
    $row = Twitter_Parser::process_json_item($item, true);
    $rdf->add_row($row, "rss:link");
}
//$rdf->add_triple("","dc:source", $url);
//footer
$rdf->end();
class Twitter_Parser
{
    static function get_rss_link($username)
    {
        $url = "http://twitter.com/{$username}";
        $content = file_get_contents($url);
        if (preg_match_all("/https?:[^\\s<>\"',]+/", $content, $matches)) {
            foreach ($matches[0] as $match) {
                $rev = strrev($match);
                if (strncmp("ssr.", $rev, 4) === 0) {
                    return $match;
                }
            }
        }
        return false;