Funcionando!
Ojo hay que instalar OpenSLL desde aqui:
http://slproweb.com/download/Win32OpenS ... 1_0_1e.exe
Code: Select all
#include "FiveWin.ch"
#include "c:\harbour\contrib\hbcurl\hbcurl.ch"
#define HB_CURLOPT_RETURNTRANSFER 500
#define OUTFILE "gmail.xml"
function Main()
local hCurl, aMatch, cPage, cAction
curl_global_init()
if ! Empty( hCurl := curl_easy_init() )
curl_easy_setopt( hCurl, HB_CURLOPT_URL, "https://mail.google.com/mail/feed/atom" )
curl_easy_setopt( hCurl, HB_CURLOPT_FOLLOWLOCATION, 1 )
curl_easy_setopt( hCurl, HB_CURLOPT_RETURNTRANSFER, 1 )
curl_easy_setopt( hCurl, HB_CURLOPT_SSL_VERIFYPEER, .F. )
curl_easy_setopt( hCurl, HB_CURLOPT_USERPWD, "antonio.fivetech" + ":" + "yourpassword" )
curl_easy_setopt( hCurl, HB_CURLOPT_HTTPAUTH, HB_CURLAUTH_BASIC )
curl_easy_setopt( hCurl, HB_CURLOPT_DL_FILE_SETUP, OUTFILE )
curl_easy_perform( hCurl )
curl_easy_reset( hCurl )
endif
curl_global_cleanup()
if File( OUTFILE )
ParseXML()
endif
return nil
function ParseXML()
local hFile := FOpen( OUTFILE )
Local oXmlDoc := TXmlDocument():New( hFile )
Local oXmlIter := TXmlIterator():New( oXmlDoc:oRoot ), oTagActual
local aItems := {}, oEmail
while .T.
oTagActual = oXmlIter:Next()
If oTagActual != nil
if Upper( AllTrim( oTagActual:cName ) ) == "TITLE"
if oEmail != nil
AAdd( aItems, { oEmail:cDate, oEmail:cAuthorName, oEmail:cTitle } )
endif
oEmail = TEmail():New()
oEmail:cTitle = oTagActual:cData
endif
if Upper( AllTrim( oTagActual:cName ) ) == "ISSUED"
oEmail:cDate = oTagActual:cData
endif
if Upper( AllTrim( oTagActual:cName ) ) == "AUTHOR"
oTagActual = oXmlIter:Next()
oEmail:cAuthorName = oTagActual:cData
oTagActual = oXmlIter:Next()
oEmail:cAuthorEmail = oTagActual:cData
endif
// HEval( oTagActual:aAttributes, { | cKey, cValue | MsgInfo( cKey, cValue ) } )
Else
Exit
Endif
End
FClose( hFile )
XBROWSER aItems ;
SETUP ( oBrw:aCols[ 1 ]:cHeader := "Date",;
oBrw:aCols[ 2 ]:cHeader := "From",;
oBrw:aCols[ 3 ]:cHeader := "Title" )
return nil
CLASS TEmail
DATA cTitle
DATA cDate
DATA cAuthorName
DATA cAuthorEmail
ENDCLASS