Page 2 of 3

Re: API Google. Ejemplos

PostPosted: Sun Jan 20, 2013 12:51 pm
by Andrés González
Veo que parece que el calendar y el task son dos cosas completamente distintas, pese a que se presentan en el google calendar. El tasks parece que tiene una API distinta a la del google calendar: https://developers.google.com/google-apps/tasks/. Intentaré volver a el cuando entienda plenamente el google calendar.

Softruz, una cosa a ver si lo entiendo bien, cuando intento recuperar todos los calendarios, me devuelve el siguiente mensaje:
Valid calendar id must be supplied to favorites list in allcalendars projection


A que crees que se debe esto, ya que yo solo tengo un calendario particular de mi cuenta y recibo otro corporativo, y además el tema del task. No tocaria devolverme todos los calendarios, no sé, en un mensaje. Seguro que algo no hago bien, pero tu alta me la realiza cada vez en mi calendario particular. Estoy traduciendo la API del calendar para enterarme y se ve muy atractiva, pero hay cosas que no acabo de entender.

PD.: Veo que si cambio el codigo y pido los calendarios de los que soy propietario, me da un mensaje con todos menos con el task.
Code: Select all  Expand view
//Recivir los calendarios que es propietario
strURL:="https://www.google.com/calendar/feeds/default/owncalendars/full"
strFormData = cEventCode
cResponse:=SendPostToUrl( strURL, strFormData,"application/atom+xml","GoogleLogin auth=" + AuthCode)
msginfo(cResponse)

Re: API Google. Ejemplos

PostPosted: Tue Jan 27, 2015 6:59 pm
by Baxajaun
Buenas tardes/noches,

os funciona el ejemplo ?

Error description: Error BASE/2017 Argument error: AEVAL
Args:
[ 1] = C Error=BadAuthentication
Url=https://www.google.com/accounts/ContinueSignIn?sarp=1&scc=1&plt=AKgnsbs1KwuanYVX57I9skPc7lfZZ9qo1K2XspKkXVZ7ujC8HankbPNodlMzjTe5X_PCD8iIoMw1Npuk4qe4eMR0yvF8OAe-Jy0PPjRpraPI9eA6K5oFBx-IPOlHSiz_4CPZe4nDCBOUTqDexSbGlwpqBv8Iv-QOikQL9YwXMtOlQoIOR-oALtbUVmg2VjSty_79dvYpDPXLI4eewLyy12ZP7dlwU0TXOA
Info=WebLoginRequired

[ 2] = B {|| ... }

Stack Calls
===========
Called from: => AEVAL( 0 )
Called from: calendar.prg => SENDPOSTTOURL( 46 )
Called from: calendar.prg => MAIN( 7 )

Muchas gracias.

Saludos

Re: API Google. Ejemplos

PostPosted: Tue Jan 27, 2015 8:50 pm
by Andrés González
Felix, primero tienes que utilizar una cuenta Google o cuenta dependiendo de google. Nosotros tenemos el correo corporativo en google fíjate elimino mi password que tendrias que poner el tuyo. Mi cuenta es agonzalez@calvia.com y funciona bien ya que es igual que si fuera una cuenta gmail. El dominio por así decirlo redirigido lo puedes contratar en google y asi tienes todas las funcionalidades como agonzalez@gmail.com esta te la dan gratis pero si quieres hacer uno de tu empresa te cuesta dinero, para eso tienes que hablar con algún comercial, pero después tienes un montón de ventajas (la site, el drive, el calendar y mil cosas mas de google) creo que ha sido el mejor cambio que hemos hecho en mi empresa. Si quieres mas información dime cosas ya que eso marca mucho la diferencia con los correos corporativos que no son de google.

Los msginfo deberían devolverte una pantalla con un montón de códigos ilegibles.

Code: Select all  Expand view

////////////////////////////////
// Codigo Fuente
////////////////////////////

#include "FiveWin.ch"

Function Main()

//Autenticación
local strURL:= "https://www.google.com/accounts/ClientLogin",AuthCode:=""
local strFormData,myEmail:="agonzalez@calvia.com",myPassword:="aquielpasword",mySource:="project-example-1",cRespone:=""
strFormData = "Email=" + myEmail + "&Passwd=" + myPassword + "&source=" + mySource + "&service=cl"
cResponse:=SendPostToUrl( strURL, strFormData )
msginfo(cResponse)
AuthCode = Right(cResponse, Len(cResponse) - at("Auth=",cResponse) - 4)
msginfo(AuthCode)

cEventCode:=getEventCode(date(),"Test Event","Event Description","Your Name","Email","Cordoba")
msginfo(cEventCode)

// Añadir un nuevo evento
strURL = "http://www.google.com/calendar/feeds/default/private/full"
strFormData = cEventCode
cResponse:=SendPostToUrl( strURL, strFormData,"application/atom+xml","GoogleLogin auth=" + AuthCode)

// Recivir los calendarios
strURL:="https://www.google.com/calendar/feeds/default/allcalendars/full"
strFormData = cEventCode
cResponse:=SendPostToUrl( strURL, strFormData,"application/atom+xml","GoogleLogin auth=" + AuthCode)
msginfo(cResponse)

//Recivir los calendarios que es propietario
strURL:="https://www.google.com/calendar/feeds/default/owncalendars/full"
strFormData = cEventCode
cResponse:=SendPostToUrl( strURL, strFormData,"application/atom+xml","GoogleLogin auth=" + AuthCode)
msginfo(cResponse)

Return Nil

Function SendPostToUrl( cUrl, cParams,cContentType,cAuthorization )
Local oOle,cRet:='',uRet
default cContentType:="application/x-www-form-urlencoded"
default cAuthorization:=""
Try
oOle := CreateObject( 'MSXML2.XMLHTTP' )
Catch
oOle := CreateObject( 'Microsoft.XMLHTTP' )
End
oOle:Open( 'POST', cUrl, .f. )

oOle:SetRequestHeader( "Content-Type",cContentType)
if !empty(cAuthorization)
oOle:SetRequestHeader( "Authorization",cAuthorization)
end if

oOle:Send( cParams )
SysRefresh()

#ifdef __XHARBOUR__
cRet := oOle:ResponseBody
#else
AEval(oOle:ResponseBody,{|uRet|cRet+=Chr(uRet)})
#endif
Return cRet

function dtos_format(fecha)
local cadena
if valtype(fecha) = "D"
cadena:=dtos(fecha)
if !empty(cadena)
return substr(cadena,1,4) + "-" + substr(cadena,5,2) + "-" + substr(cadena,7,2)
else
return "0000-00-00"
end if
else
return "0000-00-00"
end if
return "0000-00-00"

static function getEventCode(dDate,cEventName,cEventDescription,cYourName,cEmailAddress,cLocation,cStartTime,cEndTime)
local formattedDate:=""
default cStartTime:="17:00:00",cEndTime:="18:00:00"

// 'change the date into Google's yyyy-mm-dd format
formattedDate = dtos_format(dDate)

getEventCode = "<entry xmlns='http://www.w3.org/2005/Atom'" + CRLF +;
"xmlns:gd='http://schemas.google.com/g/2005'>" + CRLF +;
" <category scheme='http://schemas.google.com/g/2005#kind'" + CRLF +;
"term='http://schemas.google.com/g/2005#event'></category>" + CRLF +;
" <title type='text'>" +cEventName+ "</title>" + CRLF +;
"<content type='text'>" +cEventDescription+ "</content>" + CRLF +;
"<author>" + CRLF +;
"<name>" +cYourName+ "</name>" + CRLF +;
"<email>" +cEmailAddress+ "</email>" + CRLF +;
"</author>" + CRLF +;
"<gd:transparency" + CRLF +;
"value='http://schemas.google.com/g/2005#event.opaque'>" + CRLF +;
"</gd:transparency>" + CRLF +;
"<gd:eventStatus" + CRLF +;
"value='http://schemas.google.com/g/2005#event.confirmed'>" + CRLF +;
"</gd:eventStatus>" + CRLF +;
"<gd:where valueString='" +cLocation+ "'></gd:where>" + CRLF +;
"<gd:when startTime='" + formattedDate + "T" + cStartTime+"'" + CRLF +;
"endTime='" + formattedDate + "T" + cEndTime+"'></gd:when>" + CRLF +;
"</entry>"
return getEventCode
 

Re: API Google. Ejemplos

PostPosted: Wed Jan 28, 2015 8:37 pm
by Baxajaun
Andrés,

me sigue dando el mismo error.

Muchas gracias.

Saludos

Re: API Google. Ejemplos

PostPosted: Fri Jan 30, 2015 5:04 am
by cnavarro
Felix, a mi me da el mismo error que a ti
En mi cuenta de correo recibo un mail indicándome que alguien ha intentado acceder a la cuenta

Andres, sabes por qué puede ocurrir esto?

Re: API Google. Ejemplos

PostPosted: Fri Jan 30, 2015 5:25 am
by Baxajaun
Buenos días,

creo que necesitamos una clave para poder usar las APIs de Google. A los que les haya funcionado el ejemplo, lo podriais probar ahora ?

Creo que ha cambiado la política de Google y ahora se necesita una clave para usar las APIs.

Muchas gracias.

Saludos

Re: API Google. Ejemplos

PostPosted: Fri Jan 30, 2015 11:57 am
by RenOmaS
Buenas
Creo que tienen que tner activado esto en sus cuentas
https://www.google.com/settings/security/lesssecureapps

Pero igual me da error
Code: Select all  Expand view
Application
===========
   Path and name: D:\Test\Fivedit\noname.exe (32 bits)
   Size: 3,023,360 bytes
   Compiler version: Harbour 3.2.0dev (r1412151448)
   FiveWin  Version: FWH 15.01
   Windows version: 6.1, Build 7600

   Time from start: 0 hours 0 mins 2 secs
   Error occurred at: 01/30/15, 10:40:35
   Error description: Error BASE/2017  Argument error: AEVAL
   Args:
     [   1] = C   SID=DQAAACEBAAAG0-gguZW0_71c9quEUxxSk_MGCYhEUtocQ5eF0UZmYYYKKONL6nIa43AcL27b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poos0fWifZQbrfM5AG6Q9AAlolc_uGK-pgo-wNqDJTgYrClnrcFBJNsJZqeyQfLo2p_TufKZSLmxqzpz3fhiK-7Zd1ZeiFUZbdpNoTkLyL7wy

     [   2] = B   {|| ... }

Stack Calls
===========
   Called from:  => AEVAL( 0 )
   Called from: noname.prg => SENDPOSTTOURL( 55 )
   Called from: noname.prg => MAIN( 10 )
 


Se supone que oOle:ResponseBody deve ser un array pero es una cadena.

Re: API Google. Ejemplos

PostPosted: Fri Jan 30, 2015 12:21 pm
by cnavarro
Ya lo he intentado tambien
Es porque hay que darse de alta como usuario, te dan 60 dias de prueba ( bueno 300 $ de credito ) y luego decides si te quedas o no
O por lo menos eso es lo que he entendido

Re: API Google. Ejemplos

PostPosted: Fri Jan 30, 2015 12:27 pm
by Baxajaun
Cristobal,

puedes poner el enlace dónde has leido eso ?

Muchas gracias.

Saludos

Re: API Google. Ejemplos

PostPosted: Fri Jan 30, 2015 6:39 pm
by Baxajaun
Esto es lo que me han comentado:

Claro es muy sencillo, lo único que debes hacer es crear un proyecto en la consola de administración
https://console.developers.google.com
En credenciales te dará un ID de cliente y una llave, la cuál usarás para cualquiera de las APIs y son gratuitas y fácil de implementar.

Saludos

Re: API Google. Ejemplos

PostPosted: Fri Jan 30, 2015 7:00 pm
by cnavarro
Vale, ya he creado el proyecto, y he ido al apartado "Crear ID Cliente Nuevo" y despues a "Crear Clave Nueva"
Felix, como se implementa en el ejemplo?

Re: API Google. Ejemplos

PostPosted: Fri Jan 30, 2015 7:39 pm
by Baxajaun
Hola Cristobal,

yo también he creado un proyecto. Lo estoy intentando con el ejemplo de softcruz y Andrés, con los datos del proyecto nuevo creado. Si consigo algo os cuento.

Saludos

Re: API Google. Ejemplos

PostPosted: Sat Jan 31, 2015 9:37 am
by Maurizio
Hello,
I also have problems to pass API v3 .
When you have the ID Client try :
https://accounts.google.com/o/oauth2/au ... %20profile
This return a web page . I dont know how to switch over automatically :(

Regards Maurizio

Re: API Google. Ejemplos

PostPosted: Sat Jan 31, 2015 10:13 am
by Baxajaun
Hello Maurizio,

thanks for your help. I've used two ways to ask:

- a Google's guy

- a Google's expert

when i'll have a answer from them, i'll communicate to you.

Regards

Re: API Google. Ejemplos

PostPosted: Sun Feb 01, 2015 10:17 am
by Baxajaun
Buenos días,

me han recomendado seguir este enlace

https://developers.google.com/google-apps/calendar/instantiate

Saludos