Foros del Web » Programando para Internet » PHP »

php obtener la url real de un feed

Estas en el tema de php obtener la url real de un feed en el foro de PHP en Foros del Web. hola estoy construyendo una pagina web pero esta lee un xml de feed burner y me gustaria saber la url real de link del item ...
  #1 (permalink)  
Antiguo 21/08/2013, 14:03
 
Fecha de Ingreso: diciembre-2011
Mensajes: 408
Antigüedad: 12 años, 3 meses
Puntos: 18
php obtener la url real de un feed

hola estoy construyendo una pagina web pero esta lee un xml de feed burner y me gustaria saber la url real de link del item del feed estaba probando con curl pero demora mucho

Código PHP:
Ver original
  1. function getCurlUrl($url)
  2.   {
  3.     $ch = curl_init($url);
  4.  
  5.     curl_setopt($ch, CURLOPT_HEADER, true);
  6.     curl_setopt($ch, CURLOPT_NOBODY, true);
  7.     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  8.  
  9.     $response = curl_exec($ch);
  10.     curl_close($ch);
  11.  
  12.     $header = "Location: ";
  13.     $pos = strpos($response, $header);
  14.     $pos += strlen($header);
  15.     $redirect_url = substr($response, $pos, strpos($response, "\r\n", $pos)-$pos);
  16.    
  17.     return $redirect_url;
  18.   }
  #2 (permalink)  
Antiguo 21/08/2013, 18:17
Avatar de guardarmicorreo  
Fecha de Ingreso: noviembre-2012
Ubicación: Córdoba
Mensajes: 1.153
Antigüedad: 11 años, 5 meses
Puntos: 84
Respuesta: php obtener la url real de un feed

Cita:
Iniciado por minimal Ver Mensaje
hola estoy construyendo una pagina web pero esta lee un xml de feed burner y me gustaria saber la url real de link del item del feed estaba probando con curl pero demora mucho

Código PHP:
Ver original
  1. function getCurlUrl($url)
  2.   {
  3.     $ch = curl_init($url);
  4.  
  5.     curl_setopt($ch, CURLOPT_HEADER, true);
  6.     curl_setopt($ch, CURLOPT_NOBODY, true);
  7.     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  8.  
  9.     $response = curl_exec($ch);
  10.     curl_close($ch);
  11.  
  12.     $header = "Location: ";
  13.     $pos = strpos($response, $header);
  14.     $pos += strlen($header);
  15.     $redirect_url = substr($response, $pos, strpos($response, "\r\n", $pos)-$pos);
  16.    
  17.     return $redirect_url;
  18.   }
a ver si te sirve el ejemplo 3 de preg_match()
__________________
Ayúdame a hacerlo por mi mismo.

Etiquetas: feed, real, url
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 00:37.