'
' Store a website over HTTPS into a variable - PvE december 2010
'

' Include the CURL context
INCLUDE "curl.bac"

' We store our data in this variable
DECLARE mail$

' Callback to let Curl gather data
FUNCTION Save_Data(STRING buffer$, size_t size, size_t nmemb, void *userp)

    mail$ = CONCAT$(mail$, buffer$)
    RETURN size*nmemb

END FUNCTION

' Create the handle
easyhandle = curl_easy_init()

' Set the options
curl_easy_setopt(easyhandle, CURLOPT_URL, "https://mail.google.com/mail/feed/atom")
curl_easy_setopt(easyhandle, CURLOPT_USERPWD, "name:passwd")
curl_easy_setopt(easyhandle, CURLOPT_WRITEFUNCTION, Save_Data)

' Perform the GET
success = curl_easy_perform(easyhandle)

' Cleanup
curl_easy_cleanup(easyhandle)

' Print result
PRINT mail$

' Print Curl version
PRINT "Using CURL version: ", curl_version$(), NL$