Get gmail contacts with libcurlssl

BlitzMax Modules Forums/Brucey's Modules/Get gmail contacts with libcurlssl

Below is a very rough example of using the google api to get a list of contacts from a gmail account.

Google has an api for their calender too, that you can use in a similar way.

This code exits with a "compile error" when run from the IDE.

Does somebody know why?


' Date: 2008.03.29
' libcurlssl example by Peter Scheutz
' Get contacts from a gmail account
' Get some info on the google api here:
' <a href="http://code.google.com/apis/contacts/developers_guide_protocol.html#client_login" target="_blank">http://code.google.com/apis/contacts/developers_guide_protocol.html#client_login</a>

' the windows binary for opensll here:
' <a href="http://www.slproweb.com/products/Win32OpenSSL.html" target="_blank">http://www.slproweb.com/products/Win32OpenSSL.html</a>

SuperStrict

Import  BaH.libcurlssl

Const user:String = "somebody@..."
Const pass:String = "secretcode"


Local curl:TCurlEasy = TCurlEasy.Create()

Local data:String = "accountType=GOOGLE&Email=" + user + "&Passwd=" + pass + "&service=cp&source=exampleCo-exampleApp-1"


curl.setWriteString()
curl.setOptInt(CURLOPT_VERBOSE, 1)
curl.setOptInt(CURLOPT_FOLLOWLOCATION, 1)
curl.setOptInt(CURLOPT_SSL_VERIFYPEER, 0); 
curl.setOptString(CURLOPT_POSTFIELDS, data)
curl.setOptString(CURLOPT_URL, "https://www.google.com/accounts/ClientLogin")

Local res:Int = curl.perform()

Local myarr:String[] =  curl.tostring().split("~n")
Local auth:String 

For Local s:String = EachIn myarr
	If Lower(Left$(Trim(s),5)) = "auth="
		auth = Trim(s)
	EndIf
Next

curl.cleanup()
curl = Null

' Start over and get the contacts:
curl:TCurlEasy = TCurlEasy.Create()

curl.setWriteString()
curl.setOptInt(CURLOPT_VERBOSE, 1)
curl.setOptInt(CURLOPT_FOLLOWLOCATION, 1)
curl.setOptInt(CURLOPT_SSL_VERIFYPEER, 0); 


curl.httpHeader(["Authorization: GoogleLogin " + auth]) 

curl.setOptString(CURLOPT_URL, "http://www.google.com/m8/feeds/contacts/"+user+"/base")
res = curl.perform()

' If all went well this is the xml:
Notify(Trim(curl.tostring()))


curl.cleanup()


It's a ghost compile error. The IDE processes the stdio streams and believes that a time in the stream matches the template for determining that an error occurred during compilation.

Nice example, btw :-)