Download from given URL to a file, with https(SSL) support
int okutil_http_download( LPCSTR lpcszURL, LPCSTR lpcszFileName, int nConnectTimeout = 0, int nResponseTimeout = 0, BOOL bIgnoreCertError = FALSE )
Return OHTTP_E_OK for success, other negative values are error code.
//assume active book empty void stock() { string strSymbol = "MSFT";//you need apikey if searching any other stock string strFile = GetOriginPath(ORIGIN_PATH_USER) + strSymbol + "_stock.csv"; string strURL = "https://www.alphavantage.co/query?function=TIME_SERIES_DAILY&symbol="; strURL += strSymbol; strURL += "&apikey=demo&datatype=csv"; string result; int err = okutil_http_download(strURL, strFile); if( err != 0 ) { out_int("err = ", err); return; } Worksheet wks = Project.ActiveLayer(); ASCIMP ai; if(AscImpReadFileStruct(strFile, &ai)==0) { ai.iSubheaderLines = 1; ai.nLongNames = 1; wks.ImportASCII(strFile, ai); Column col(wks, 0); col.SetFormat(OKCOLTYPE_DATE, "yyyy'-'MM'-'dd"); } }
origin.h