FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour FWH and Google Tables
Posts: 1392
Joined: Mon May 14, 2007 09:49 AM
FWH and Google Tables
Posted: Tue Sep 08, 2020 04:25 PM

Hi,

Can I work with Google Tables from FWH ?

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: FWH and Google Tables
Posted: Wed Sep 09, 2020 06:38 AM
Yes, you have to use curl:

Code (fw): Select all Collapse
#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,)
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1392
Joined: Mon May 14, 2007 09:49 AM
Re: FWH and Google Tables
Posted: Thu Sep 10, 2020 10:13 AM

Thank You, Antonio ! I will try

Posts: 16
Joined: Thu Jan 22, 2009 06:24 AM
Re: FWH and Google Tables
Posted: Sun Sep 13, 2020 09:09 AM

What file *.bat from Fwh\samples should be used for assembly of this example?
It Harbour or xHarbour?
What else files (dll) are necessary for its work?
I did not find "hbcurl.ch"

Many thanks!

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: FWH and Google Tables
Posted: Sun Sep 13, 2020 09:22 AM
hbcurl.ch is available from:
https://github.com/harbour/core/tree/master/contrib/hbcurl

Use Harbour

You may use FWH\samples\buildh.bat if you want to use CURL from a FWH app, or simply use FWH\samples\build.bat if you don't want to include FWH
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1392
Joined: Mon May 14, 2007 09:49 AM
Re: FWH and Google Tables
Posted: Wed Jan 20, 2021 08:00 PM

Is it possible to run a google table macro using cURL ?

Continue the discussion