Wednesday, 21 August 2013

Google calendar by PHP cURL returned strings in German

Google calendar by PHP cURL returned strings in German

I'm trying to retrieve the Google calendar XML using cURL to display it in
my application.
The calender is public and it can be directly accessed via browser:
https://www.google.com/calendar/feeds/en.usa%23holiday%40group.v.calendar.google.com/public/basic
When I tried to get it from my program, it is strangely returned in
German. Here it is

Below is my code:
$xml = NULL;
$url =
'https://www.google.com/calendar/feeds/en.usa%23holiday%40group.v.calendar.google.com/public/basic';
$crl = curl_init();
curl_setopt ($crl, CURLOPT_URL, $url);
curl_setopt ($crl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($crl, CURLOPT_CONNECTTIMEOUT, 15);
$xml = curl_exec($crl);
curl_close($crl);
echo '<pre>';
print_r($xml);
exit;
if($xml){
$xml = simplexml_load_string($xml);
}
When the URL is run from the browser, it is returned in English. I thought
that it is because of the cURL proxy settings on the server, then I tried
to add those two lines, but it did not make sense.
curl_setopt ($crl, CURLOPT_HTTPGET, TRUE);
curl_setopt ($crl, CURLOPT_HTTPPROXYTUNNEL, FALSE);
Any idea? Please help.

No comments:

Post a Comment