FWH and Google Tables

FWH and Google Tables

Postby Natter » Tue Sep 08, 2020 4:25 pm

Hi,

Can I work with Google Tables from FWH ?
Natter
 
Posts: 1221
Joined: Mon May 14, 2007 9:49 am

Re: FWH and Google Tables

Postby Antonio Linares » Wed Sep 09, 2020 6:38 am

Yes, you have to use curl:

Code: Select all  Expand view
#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
User avatar
Antonio Linares
Site Admin
 
Posts: 42099
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: FWH and Google Tables

Postby Natter » Thu Sep 10, 2020 10:13 am

Thank You, Antonio ! I will try
Natter
 
Posts: 1221
Joined: Mon May 14, 2007 9:49 am

Re: FWH and Google Tables

Postby MMK » Sun Sep 13, 2020 9: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!
MMK
 
Posts: 13
Joined: Thu Jan 22, 2009 6:24 am

Re: FWH and Google Tables

Postby Antonio Linares » Sun Sep 13, 2020 9: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
User avatar
Antonio Linares
Site Admin
 
Posts: 42099
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: FWH and Google Tables

Postby Natter » Wed Jan 20, 2021 8:00 pm

Is it possible to run a google table macro using cURL ?
Natter
 
Posts: 1221
Joined: Mon May 14, 2007 9:49 am


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 28 guests