0
votes

Below is the code. It seems to not be opening the google calendar at all. I believe it has something to do with the url I am using and possbily the special character. I get the following:

Warning: DOMDocument::loadHTMLFile() [domdocument.loadhtmlfile]: I/O warning : failed to load external entity "https://www.google.com/calendar/feeds/[email protected]/public/basic" on line 4

<?
$dom = new DOMDocument(); 
$feed = "https://www.google.com/calendar/feeds/[email protected]/public/basic";
$html = $dom->loadHTMLFile($feed);
$dom->preserveWhiteSpace = true;
$entries = $dom->getElementsByTagName("entry"); 


foreach ( $entries as $entry ) 
{ 

    $status = $entry->getElementsByTagName( "eventStatus" ); 
    $eventStatus = $status->item(0)->getAttributeNode("value")->value;

    if ($eventStatus == $confirmed) 
 {
        $titles = $entry->getElementsByTagName( "title" ); 
        $title = $titles->item(0)->nodeValue;

        $times = $entry->getElementsByTagName( "when" ); 
            $startTime = $times->item(0)->getAttributeNode("startTime")->value;
            $when = date( "l jS \o\f F Y - h:i A", strtotime( $startTime ) );

            $places = $entry->getElementsByTagName( "where" ); 
            $where = $places->item(0)->getAttributeNode("valueString")->value;

            print $title . "\n"; 
            print $when . " AST\n"; 
            print $where . "\n"; 
            print "\n"; 
        }
    }
?>
1

1 Answers

0
votes

As far as I know, DOMDocument::loadHTMLFile() is capable of negotiating SSL, but if it is failing you might try file_get_contents() to read the file first into a string.

$dom = new DOMDocument(); 
$feed = "https://www.google.com/calendar/feeds/[email protected]/public/basic";
$feed_string = file_get_contents($feed);
$html = $dom->loadHTMLFile($feed_string);

This is fully speculative though. Treat it as such.

EDIT Make sure that allow_url_fopen is enabled in your php.ini.