How to Import Google Contacts Info

margret

Well-Known Member
Licensed User
Longtime User
Hello,

I really need to be able to read/import google contacts into B4A. This is in an app I am writing. The user can provide the authorization needed. I have looked for days and can find nothing that gives what I am looking for. I don't care about the email/messages, etc. Just the contact info and everything that in stored in the info record. Can this be done in B4A? Please any info would be great.

Thanks,

Margret
 

margret

Well-Known Member
Licensed User
Longtime User
Update

Hello thedesolatesoul,

I am in shock. I still don't have this working... I could not believe the amount of code that is there to do this, I am floored. This may take a long while if then. Seems like Google could of made a better way. This is nuts just to pull contacts. I will press on and report if I make any progress but it will be ssllloooooowwwww..

To pull this together like you did, my hats off to you, Master.....:sign0188:

Thanks,

Margret
 
Upvote 0

thedesolatesoul

Expert
Licensed User
Longtime User
Its not that much code.
Actually I used Erel's HttpUtils module and service to do one request. This wasnt probably necessary but in development I didnt really know what functions I would need and HttpUtils had most of them.
You could probably remove those other modules and just replace them with an HttpClient in Main.
I only wrote the code in Main. Just tried to get the sequence and requests right.
Let me know if it does not work, it should be quite straightforward.
 
Upvote 0

margret

Well-Known Member
Licensed User
Longtime User
Import Contacts

Hello Again,

I created the ID and secret code. I put them in the code and ran it. It comes up and ask to login and then says My App wan't access, Allow or Cancel. When you say yes, it returns another code and says to copy it and paste it in the application to continue. I don't know why, or what to do at that point. Did you see the same thing??? Any ideas? It works, I just don't know what to do with that returned code, it's about 20 characters long alpha-numbers.

Thanks,

Margret
 
Upvote 0

thedesolatesoul

Expert
Licensed User
Longtime User
Okay there are 3 steps:

Step1: Where the webview sign in, and returns to you an "Authorization Code". This is what you are seeing.

Step2: You use the Authorization code to request an Access Token. This is done "automatically" as soon as the webview page loads (look in webview_pagefinished or something like that to see how it is done). If you turn on the Logs you can see the Access Token coming back.

Step3: When you see the AccessToken coming back in the logs, press the Get Contacts button, and it will load the contacts in the webview (although in xml).

I know the code structure can be improved but all of this can be automated according to your own requirements.
 
Upvote 0
Top