Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in /data/e/7/e76990b9-3372-4d88-8089-fce36e16744a/webperfection.net/sub/rady-nosu/wp-content/plugins/seo-ultimate/modules/class.su-module.php on line 1195
google weather unsupported api - XML parsing failed - not available

August 27, 2012 | In: Programovanie

google weather unsupported api – not available

Unsupported API – not available

seems that google api is out

google.com/ig/api?weather

if u dont, wrap simplexml_load_string in try/catch in php and use user error handling for xml:

try { $data = simplexml_load_string(...); catch( Exception $e ) { // error // do something with this $data }

real example:

... method ... $data = @file_get_contents($this->getApiUrl("", "Slovakia")); if(!$data) { return false; }; $data = iconv("ISO-8859-2", 'utf-8', $data); // enable user error handling libxml_use_internal_errors(true); // load the document $doc = new DOMDocument; if (!$doc->load($data)) { libxml_clear_errors(); return false; } try { $xmlData = new SimpleXMLElement($data); } catch (Exception $e) { return false; } return true; ... end method ...

or simple:

libxml_use_internal_errors(true); try{ $xmlObject = new SimpleXMLElement($wrongFormedText); } catch (Exception $e){ return false; }

1. always use error reporting 0!
2. do not dispaly ANY error on production!
2. wrap all your services for error handling

Share This:

Comments are closed.