Exemplo n.º 1
0
$url = "https://spreadsheets.google.com/feeds/list/t4GxaAbYL-dqlxi3iTy-b7w/od6/public/values/";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$xml = curl_exec($ch);
curl_close($ch);
//$doc = new DOMDocument();
//$doc->loadXML($xml);
//$entries = $doc->getElementsByTagName("gsx:projecttitle");
//if ($entries->length > 0) {
//	foreach($entries as $e) {
//		echo $e;
//	}
//}
$items = element_set('entry', $xml);
$c = 1;
foreach ($items as $i) {
    $content = value_in('gsx:projecttitle', $i);
    $name = value_in('gsx:fullnamesanddegreese.g.johne.smithmdphd', $i);
    $contact = value_in('gsx:nrnbcontact', $i);
    echo "<tr><td>" . $c++ . "<td>{$content}<td>{$name}<td>{$contact}</tr>";
}
$title = value_in('title', $xml);
$link = value_in('link', $xml);
function value_in($element_name, $xml, $content_only = true)
{
    if ($xml == false) {
        return false;
    }
    $found = preg_match('#<' . $element_name . '(?:\\s+[^>]+)?>(.*?)' . '</' . $element_name . '>#s', $xml, $matches);
function getBlogFromAtomFeed($xml, $url)
{
    $blog = array('title' => value_in('title', $xml), 'entries' => array());
    $entries = element_set('entry', $xml);
    if ($entries === NULL || $entries === false) {
        throw new Exception("XML parse error: could not find post entries; check your feed URL and make sure it is publicly accessible.  You should be able to see your posts here: {$url}");
    }
    foreach ($entries as $entry) {
        $tags = array();
        $cats = element_set('category', $entry);
        if (!empty($cats)) {
            foreach ($cats as $cat) {
                $category = element_attributes('category', $cat);
                // Blogger puts tags in reverse order, so prepend like a queue
                // instead of pushing like a stack.  (Not that order really matters,
                // but some people might care.)
                array_unshift($tags, unhtmlentities($category['term']));
            }
        }
        // Check for summary.  Blogger only includes summary if content isn't.
        $entry_body = unhtmlentities(value_in('content', $entry));
        $entry_summary = value_in('summary', $entry);
        if (empty($entry_body) && !empty($entry_summary)) {
            throw new HtmlSafeException("It looks like your blog's feed settings are only showing summaries, and this is preventing me from seeing your full posts.  Change your <a href=\"http://www.google.com/support/blogger/bin/answer.py?hl=en&amp;answer=42662\" target=\"_blank\">blog posts feed settings</a> to \"Full\".");
        }
        $blog['entries'][] = array('title' => unhtmlentities(value_in('title', $entry)), 'timestamp' => date('Y-m-d H:i:s', strtotime(value_in('published', $entry))), 'body' => $entry_body, 'tags' => $tags);
    }
    return $blog;
}