Foros del Web » Programando para Internet » PHP » Frameworks y PHP orientado a objetos »

Problema con API de Picasa y PHP

Estas en el tema de Problema con API de Picasa y PHP en el foro de Frameworks y PHP orientado a objetos en Foros del Web. Buenas a todos. Estoy trabajando con PHP orientado a objetos y la API de Picasa para que los usuarios de mi web pueden ver y ...
  #1 (permalink)  
Antiguo 09/04/2010, 05:20
 
Fecha de Ingreso: abril-2010
Mensajes: 2
Antigüedad: 14 años
Puntos: 0
Problema con API de Picasa y PHP

Buenas a todos.

Estoy trabajando con PHP orientado a objetos y la API de Picasa para que los usuarios de mi web pueden ver y subir fotos a Picasa. He conseguido visualizar las fotos pero mi problema surge cuando quiero crear, por ejemplo, un nuevo álbum desde mi web en Picasa. Sigo los pasos que la web de código de Google me marca, consigo el sessionToken necesario para crear contenido en Picasa pero no logro enviar el XML que genero mediante POST. Mi código es el siguiente:
Código PHP:
Ver original
  1. $url = "http://picasaweb.google.com/data/feed/api/user/
  2. diego.lopez.mesi";
  3.  
  4.    $header = Array("Content-Type: application/atom+xml",
  5. "Authorization: AuthSub token='".$_POST['sessionToken']."'",
  6. "User-Agent: Java/1.5.0_06",
  7. "Host: www.google.com",
  8. "Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2",
  9. "Connection: keep-alive");
  10.  
  11.    $xml = '<?xml version="1.0" encoding="utf-8"?>
  12. <entry xmlns="http://www.w3.org/2005/Atom" xmlns:media="http://
  13. search.yahoo.com/mrss/" xmlns:gphoto="http://schemas.google.com/photos/
  14. 2007">
  15.    <title type="text">'.$_POST['nombre'].'</title>
  16.    <summary type="text">Album de prueba</summary>
  17.    <gphoto:location>Galicia</gphoto:location>
  18.    <gphoto:access>public</gphoto:access>
  19.    <gphoto:timestamp>'.time().'</gphoto:timestamp>
  20.    <media:group>
  21.        <media:keywords>siguetuliga</media:keywords>
  22.    </media:group>
  23.    <category scheme="http://schemas.google.com/g/2005#kind"
  24. term="http://schemas.google.com/photos/2007#album"></category>
  25. </entry>';
  26.  
  27.    $ch = curl_init();
  28.  
  29.    curl_setopt($ch, CURLOPT_URL, $url);
  30.    curl_setopt($ch, CURLOPT_HEADER, TRUE);
  31.    curl_setopt($ch, CURLOPT_POST, TRUE);
  32.    curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);
  33.    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
  34.    curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
  35.    curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
  36.    var_dump(curl_exec($ch));
  37.  
  38.    curl_close($ch);
Al hacer el var_dump me muestra:
Código HTML:
Ver original
  1. string(1561) "HTTP/1.1 404 Not Found
  2. Content-Type: text/html; charset=UTF-8
  3. X-Content-Type-Options: nosniff
  4. Date: Thu, 08 Apr 2010 16:32:57 GMT
  5. Server: sffe
  6. Content-Length: 1389
  7.  
  8.  
  9.  
  10. <meta http-equiv="content-type" content="text/html;charset=utf-8">
  11. <title>404 Not Found</title>
  12. ....
  13. <H1>Not Found</H1>
  14. The requested URL <code>/data/feed/api/user/diego.lopez.mesi</code>
  15. was not found on this server.
  16. ....
  17. </html>


Alguien sabe qué es lo que estoy haciendo tan mal como para llevar
cuatro días con esto? :) Muchas gracias
  #2 (permalink)  
Antiguo 09/04/2010, 08:34
Avatar de GatorV
$this->role('moderador');
 
Fecha de Ingreso: mayo-2006
Ubicación: /home/ams/
Mensajes: 38.567
Antigüedad: 17 años, 11 meses
Puntos: 2135
Respuesta: Problema con API de Picasa y PHP

Pues si te fijas el error, dice que no existe la URL donde estas haciendo el POST.

Saludos.
  #3 (permalink)  
Antiguo 10/04/2010, 04:45
 
Fecha de Ingreso: abril-2010
Mensajes: 2
Antigüedad: 14 años
Puntos: 0
Respuesta: Problema con API de Picasa y PHP

Solucionado: simplemente necesitaba especificar en la cabecera host: picasaweb.google.com y no www.google.com, como tenía puesto. Gracias por tu respuesta GatorV.

Etiquetas: api, php, picasa
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.
Tema Cerrado




La zona horaria es GMT -6. Ahora son las 03:35.