[PHP-ES] Leer archivo externo.
[email protected] (Ricardo Vila)
| Newsgroups | php.general.es |
|---|---|
| Message-ID | <[email protected]> |
Buenas Listeros,
Quisiera hacer una consulta, tengo la necesidad de leer un archivo externo,
pero este archivo es un archivo de tipo rss es decir cuando lo ejecuto del
navegador me muestra la data y si le doy ver codigo fuente me muesta la
siguiente estructura
<?xml version="1.0" encoding="ISO-8859-1"?>
<rss version="2.0" xmlns:nsp="http://www.nokia.com/nsp/1.0/" >
<channel>
<title>Configuracion inicial</title>
<link>http://www.miweb.com</link>
<description>Configuracion inicial</description>
<nsp:channelExt sIndx="1" numRsltPp="26" ><nsp:mRslt cat="tot" n="21"/>
</nsp:channelExt>
<item>
<title>3.Valor1</title>
<description>Descripcion </description>
<nsp:itemExt type="tipo">
<nsp:coord lat="" long=""/>
</nsp:itemExt>
</item>
......
.......
</channel></rss>
quise usar file_get_contents, pero me da error 500 y me dice "failed to open
stream"
Quise usar CURL mediante un ejemplo y me imprime el siguiente error
codigo Curl:
<?php
/**
* Fetch the specified page source, even if fopen_url_wrapper is disabled
* For that purpose, we use the curl wrapper. It should work everywhere
*
* @param String $url The url to fetch
* @return String The page source code
*/
function getPage($url="http://www.example.com/"){
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL, $url);
curl_setopt($ch,CURLOPT_FRESH_CONNECT,TRUE);
curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,5);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,TRUE);
curl_setopt($ch,CURLOPT_REFERER,'http://www.google.ch/');
curl_setopt($ch,CURLOPT_TIMEOUT,10);
$html=curl_exec($ch);
if($html==false){
$m=curl_error(($ch));
error_log($m);
}
curl_close($ch);
return $html;
}
$html=getPage("http://www.miweb.com./mov/mipagina/MiArchivo");
$html=htmlentities($html);
echo $html;
lo ejecuto y me devuelve :
<html><head><title>Apache Tomcat/5.0.28 - Error report</title><style><!--H1
{font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;}
H2
{font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;}
H3
{font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;}
BODY
{font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B
{font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;}
P
{font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A
{color : black;}A.name {color : black;}HR {color : #525D76;}--></style>
</head><body><h1>HTTP Status 500 - </h1><HR size="1"
noshade="noshade"><p><b>type</b> Status report</p><p><b>message</b>
<u></u></p><p><b>description</b> <u>The server encountered an internal error
() that prevented it from fulfilling this request.</u></p><HR size="1"
noshade="noshade"><h3>Apache Tomcat/5.0.28</h3></body></html>
Cabe mencionar que este archivo que deseo leer se encuentra en un servidor
tomcat y yo lo quiero leer desde otro domino con php
Como podria hacer para poder leer esa estructura y poder trabajar con ella
desde mi código php
Quizas sea algun permiso que deba configurar en el servidor tomcat o en mi
servidor php
Agradezco de antemano su ayuda
Saludos,
Ricardo Vila