HOla
Tengo el siguiente problema, sucede que tengo el siguiente codigo
<?php$url='http://www.google.com/ig/api?weather=bucaramanga';$curl; $curl = curl_init();curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 2);curl_setopt($curl, CURLOPT_HEADER, false);curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);curl_setopt($curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);curl_setopt($curl, CURLOPT_URL, $url);$result = curl_exec($curl);curl_close($curl);header('Content-Type: application/xml; charset=UTF-8'); print $result;?>
la idea es que retorne el xml que genera la pagina a la cual se le aplica el curl pero cuando lo ejecuto no arroja nada
Posiblemente no has configurado bien las directivas de Curl.
Por otro lado, es mucho mejor que para este caso uses file_get_contents (en menos líneas puedes tener resuelto el problema):
http://php.net/manual/es/function.file-get-contents.php
Algo como:
<?phpheader('Content-Type: application/xml; charset=UTF-8');echo file_get_contents('http://www.google.com/ig/api?weather=bucaramanga');
Asimismo, parece que la petición XML no es muy correcta:
<xml_api_reply version="1">
−
<weather module_id="0" tab_id="0" mobile_row="0" mobile_zipped="1" row="0" section="0">
<problem_cause data="La información no está disponible temporalmente."/>
</weather>
</xml_api_reply>