FWH and Google Tables
Posted: Tue Sep 08, 2020 4:25 pm
Hi,
Can I work with Google Tables from FWH ?
Can I work with Google Tables from FWH ?
www.FiveTechSoft.com
https://forums.fivetechsoft.com/
Code: Select all
#include "hbcurl.ch"
function Main()
? BigQuery( "select ..." )
return nil
function BigQuery( cQuery )
local hCurl, cBuffer := ""
local aData := {}
local aResult
local cUrl := "https://www.googleapis.com/bigquery/v2/projects/your_project_name/queries"
curl_global_init()
if ! empty( hCurl := curl_easy_init() )
curl_easy_setopt( hCurl, HB_CURLOPT_URL, cUrl )
curl_easy_setopt( hCurl, HB_CURLOPT_DL_BUFF_SETUP )
curl_easy_setopt( hCurl, HB_CURLOPT_HTTPAUTH, HB_CURLAUTH_BASIC )
curl_easy_setopt( hCurl, HB_CURLOPT_POST, 1 )
curl_easy_setopt( hCurl, HB_CURLOPT_HTTPHEADER, { "Content-Type:application/json" } )
curl_easy_setopt( hCurl, HB_CURLOPT_HTTPHEADER, { "Authorization: Bearer yourOauth2key" } )
curl_easy_setopt( hCurl, HB_CURLOPT_POSTFIELDS, ' { "configuration" : { "query" : { "query" : cQuery } } }' )
if curl_easy_perform( hCurl ) == 0
cBuffer = curl_easy_dl_buff_get( hCurl )
if ! empty( cBuffer )
hb_jsonDecode( cBuffer, @aData )
endif
else
? "error"
endif
endif
curl_global_cleanup()
return If( ! Empty( aData ), aData,)