php - simpleXML error with google calendar feed with pdo on server -
i using php grab google feed simplexml display on site. works fine staged on test server (no pdo). installed live on site , worked. needed update cms needed either pdo or mysqli , host installed pdo extensions. after no longer worked. here error message:
: call member function asxml() on non-object in /home/cactusta/public_html/calendar.php on line 121
here relevant part of script using:
// private feed - right-clicking 'xml' button in 'private address' section of 'calendar details'. if (!isset($calendarfeed)) {$calendarfeed = "myfeed.com/public/basic"; } // date format want details appear $dateformat="j f y"; // 10 march 2009 - see http://www.php.net/date details $timeformat="g.ia"; // 12.15am // timezone user/venue in (i.e. time you're entering stuff in google calendar.) http://www.php.net/manual/en/timezones.php has full list date_default_timezone_set('europe/london'); // how want each thing display. // default, contains bits can grab. can put ###date### in here if want to, , disable 'group date' below. $event_display="<p><b>###title###</b> - ###from### ###datestart### until ###until### ###dateend### (<a href='###link###'>add this</a>)<br>###where### (<a href='###maplink###'>map</a>)<br>###description###</p>"; // happens if there's nothing display $event_error="<p>there no events display.</p>"; // separate date header here $event_dateheader="<p><b>###date###</b></p>"; $groupbydate=true; // change above 'false' if don't want group dates. // ...and how many want display (leave @ 999 everything) $items_to_show=999; // ...and here's tell use cache. // php need able write file called "gcal.xml" in root. create file ssh'ing box , typing these 3 commands... // > touch gcal.xml // > chmod 666 gcal.xml // > touch -t 01101200 gcal.xml // if don't need this, or bit complex, change 'false' $use_cache=true; // , finally, change 'true' see lots of fancy debug code $debug_mode=false; // //end of configuration block ///////// if ($debug_mode) {error_reporting (e_all); ini_set('display_errors', 1); ini_set('error_reporting', e_all); echo "<p>debug mode on. hello there.<br>your server thinks time ".date(date_rfc822)."</p>";} // form xml address. $calendar_xml_address = str_replace("/basic","/full?singleevents=true&futureevents=true&max-results".$items_to_show."&orderby=starttime&sortorder=a",$calendarfeed); //this goes , gets future events in feed. if ($debug_mode) { echo "<p>we're going go , grab <a href='$calendar_xml_address'>this feed</a>.<p>";} if ($use_cache) { //////// //cache // $cache_time = 3600*12; // 12 hours $cache_file = $_server['document_root'].'/gcal.xml'; //xml file saved on server if ($debug_mode) {echo "<p>your cache saved @ ".$cache_file."</p>";} $timedif = @(time() - filemtime($cache_file)); $xml = ""; if (file_exists($cache_file) && $timedif < $cache_time) { if ($debug_mode) {echo "<p>i'll use cache.</p>";} $str = file_get_contents($cache_file); $xml = simplexml_load_string($str); } else { //not here if ($debug_mode) {echo "<p>i don't have valid cached copy.</p>";} $xml = simplexml_load_file($calendar_xml_address); //come here if ($f = fopen($cache_file, 'w')) { //save info $str = $xml->asxml(); fwrite ($f, $str, strlen($str)); fclose($f); if ($debug_mode) {echo "<p>cache saved :)</p>";} } else { echo "<p>can't write cache.</p>"; } } //done! } else { $xml = simplexml_load_file($calendar_xml_address); } if ($debug_mode) {echo "<p>successfully got gcal feed.</p>";} $items_shown=0; $old_date=""; $xml->asxml();
Comments
Post a Comment