[WX] - Integrazione Google People API

Forum in Italiano NON ufficiale
Rispondi
GiovanniCarella
Messaggi: 2
Iscritto il: mar nov 16, 2021 12:42 pm

[WX] - Integrazione Google People API

Messaggio da GiovanniCarella »

Buongiorno a tutti,
finalmente sono arrivato alla conclusione dell'integrazione delle nuove People API di Google (le Contact che vengono utilizzate dalle Gglxx function di WD sono state deprecate).

Vi lascio un pezzo per creare la connessione e inviare un nuovo contatto:

Codice: Seleziona tutto


ParamOAuth is OAuth2Parameters
ParamOAuth.ClientID			= "XXXXXXXXXXXXXXXXXXXXXXXXXXXXX.apps.googleusercontent.com"
ParamOAuth.ClientSecret		= "XXXXXXXXXXXXXXXXXXXXXXXXXXXX"
ParamOAuth.AuthURL			= "https://accounts.google.com/o/oauth2/auth"
ParamOAuth.RedirectionURL	= "http://localhost:15000"
ParamOAuth.TokenURL			= "https://oauth2.googleapis.com/token"
ParamOAuth.Scope			= "https://www.googleapis.com/auth/contacts"
MyToken is AuthToken


MyToken  = AuthIdentify(ParamOAuth)
IF ErrorOccurred THEN
	Error(ErrorInfo)
END

req is WL.HTTPRequest
req.Method					= httpPost
req.ContentType				= "application/json"
req.URL						= "https://people.googleapis.com/v1/people:createContact"
req.Header["Authorization"]	= "Bearer "+MyToken..Value


j is JSON

j.addresses[1].streetAddress	= "indirizzo"
j.addresses[1].city				= "Città"
j.addresses[1].postalCode		= "CodPo"
j.addresses[1].type				= "Lavoro"
j.names[1].familyName			= "Cognome"
j.names[1].givenName			= "Nome"
j.organizations[1].name			= "Azienda di prova"
j.phoneNumbers[1].value			= "NumTelefono"
j.phoneNumbers[1].type			= "Lavoro"
j.phoneNumbers[2].value			= "NumCellulare"
j.phoneNumbers[2].type			= "Mobile"
j.emailAddresses[1].value		= "mia@mail.com"
j.emailAddresses[1].type		= "Lavoro"


req.Content						= j
resp is WL.httpResponse = HTTPSend(req)

Spero sia utile a qualcuno
Rispondi