Jump to content
Fivewin Brasil

Rotina para gravar backup Google Drive - Resolvido


Jmsilva

Recommended Posts

@cnavarro 

Error description: Error BASE/1123  Argument error: HB_HHASKEY
Called from:  => HB_HHASKEY( 0 )
Called from: .\source\internal\TGOOGLE.PRG => TGMAIL:GETTOKENS( 346 )
Called from: .\source\internal\TGOOGLE.PRG => TGMAIL:ACTIVATE( 206 )
Called from: Gmail.prg => GMAIL0( 591 )
Called from: Gmail.prg => (b)WEBBTTS( 224 )
Abraço!

JMSilva

Link to comment
Share on other sites

oMail := TGMail():New()
   //oMail:myEmail  := "navarro.cristobal@gmail.com"
   //oMail:myEmail  := "silva.ifsp@gmail.com"
   oMail:cRefreshFile := "C:\ROOT\google\refresh_id.json"
   //oMail:cRefreshFile := "C:\ROOT\google\client_id.json"
   //oMail:cJSonFile := "C:\ROOT\google\client_id.json"
   oMail:cJSonFile := "C:\ROOT\google\refresh_id.json"

 

Link to comment
Share on other sites

No, tienes que darte de alta y crear un proyecto para poder utilizar el API de Google y obtener tu API key

https://console.developers.google.com/

Borra ese fichero, no te sirve para nada:  refresh_id.json

Puedes leer mi manual, 

( Pag. 44 )

https://bitbucket.org/fivetech/harbour_novelda_2017/downloads/Cristobal_Navarro_REST.pdf

 

Link to comment
Share on other sites

 

No, tienes que darte de alta y crear un proyecto para poder utilizar el API de Google y obtener tu API key

https://console.developers.google.com/

Borra ese fichero, no te sirve para nada:  refresh_id.json

Puedes leer mi manual, 

( Pag. 44 )

https://bitbucket.org/fivetech/harbour_novelda_2017/downloads/Cristobal_Navarro_REST.pdf

 

@cnavarro Valeu! resolvido.

Obrigado!

Error description: Error BASE/1123  Argument error: HB_HHASKEY
Called from:  => HB_HHASKEY( 0 )
Called from: .\source\internal\TGOOGLE.PRG => TGMAIL:GETTOKENS( 346 )
Called from: .\source\internal\TGOOGLE.PRG => TGMAIL:ACTIVATE( 206 )
Called from: Gmail.prg => GMAIL0( 591 )
Called from: Gmail.prg => (b)WEBBTTS( 224 )
Abraço!

JMSilva

Link to comment
Share on other sites

 

Disculpa, no se si te he entendido bien

Lo has resuelto o no?

Sim, resolvido! Obrigado.

Apenas como sugestão, seria legal o tratamento referente ao parâmetro HB_HHASKEY para evitar o bug e informar o usuário. Uma vez que a classe faz leitura de arquivo e pode ocorrer diversos problemas.

Link to comment
Share on other sites

  • 3 weeks later...
  • 4 weeks later...

Pessoal,

Tentei compilar esse programa simples para fazer upload de arquivos no Google Drive, mas está dando erro:

Onde estou errando? Não funciona com xHarbour?

 

#include "Fivewin.ch"

REQUEST HB_CODEPAGE_PTISO
REQUEST HB_LANG_PT

//Para gerar as credencias pelo google vá ao site:
//https://cloud.google.com/?hl=pt-br
//1-Click sobre a palavra CONSOLE no canto superior direito
//2-Faz o login com seu_email@gmail.com
//3-Barra lateral esquerda, posicione sobre "Apis e Servicos" e
//  seleciona "Credenciais" no sub menu.
//4-Crie uma credencial para seu projeto
//5-faça donwload do arquivo .json
//copie o "Id do Cliente" em oDrive:cClientId
//copie a "Chave Secreta do Cliente" para oDrive:cSecretId

Static cKeySecret := "Hbpq8imdPdvApiQtbd5wysAY"                                                  // chave oasys
Static cClientId  := "123567890123-07vbq15j2gm4kalevad82jqcpg4ma8kp.apps.googleusercontent.com"  // id oasys
Static oDrive         

//----------------------------------------------------------------------------//
Function Main()
   HB_CDPSELECT("PTISO")
   //OU HB_SetCodePage("PTISO") // para ordenacion - requiere codepage.lib
   SET CENTURY ON

   UploadMyFile()
Return nil
//----------------------------------------------------------------------------//

Function UploadMyFile()
   local cFile  := ""
   local lSw    := .F.

   cFile := cGetFile32( "All Files (*.*) |*.*|", "Select a File to Upload" )
   MsgStop(cFile)
   if !Empty( cFile )
      oDrive  := TGDrive():New( , .T., .F. )
      //credenciais geradas pelo google
      oDrive:cJSonFile := "c:\fwh\samples\client_oasys.json"
      oDrive:cClientId := cClientId
      oDrive:cSecretid := cKeySecret

      //
      lSw     := oDrive:Activate()

      XBrowse(oDrive)

      if lSw
         if oDrive:Authorize()
            oDrive:ListFiles()  //carrega aFilesLists
            XBrowse( oDrive:aFilesLists )
            If oDrive:UpLoadFileG( cFile, , .T. )   // Last parameter .T., create shared link
               MsgInfo("Arquivo enviado com sucesso !!!","UpLoad")
            Else
               MsgStop(oDrive:cError,"UpLoad")
            Endif
         endif
      else
         MsgStop("Erro ao autenticar as credenciais do Google.","UpLoad")
      endif
   endif
Return nil

 

 

 

┌────────────────────────────────────────────────────────────────────────────┐
│ FiveWin for xHarbour 18.02 - Feb. 2018          xHarbour development power │▄
│ (c) FiveTech 1993-2018 for Microsoft Windows 9X/NT/200X/ME/XP/Vista/7/8/10 │█
└────────────────────────────────────────────────────────────────────────────┘█
  ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
Compiling...
xHarbour 1.2.3 Intl. (SimpLex) (Build 20180311)
Copyright 1999-2018, http://www.xharbour.org http://www.harbour-project.org/
Compiling 'oagmail.prg' and generating preprocessed output to 'oagmail.ppo'...
Generating C source output to 'oagmail.c'...
Done.
Lines 69, Functions/Procedures 3, pCodes 153
Embarcadero C++ 7.30 for Win32 Copyright (c) 1993-2017 Embarcadero Technologies,
 Inc.
oagmail.c:
Turbo Incremental Link 6.80 Copyright (c) 1997-2017 Embarcadero Technologies, In
c.
Error: Unresolved external '_HB_FUN___CLSLOCKDEF' referenced from C:\FWH\LIB\GOO
GLE.LIB|Tgdrive
Error: Unresolved external '_HB_FUN___CLSUNLOCKDEF' referenced from C:\FWH\LIB\G
OOGLE.LIB|Tgoogle
Error: Unresolved external '_HB_FUN_HB_HHASKEY' referenced from C:\FWH\LIB\GOOGL
E.LIB|Tgoogle
Error: Unresolved external '_HB_FUN_FW_GT' referenced from C:\FWH\LIB\GOOGLE.LIB
|Tgoogle
Error: Unresolved external '_HB_FUN___HBEXTERN__HBSSL__' referenced from C:\FWH\
LIB\GOOGLE.LIB|Tgoogle
Error: Unable to perform link
* Linking errors *

C:\FWH\samples>

 

Link to comment
Share on other sites

 

Pessoal,

Tentei compilar esse programa simples para fazer upload de arquivos no Google Drive, mas está dando erro:

Onde estou errando? Não funciona com xHarbour?

 


#include "Fivewin.ch"

REQUEST HB_CODEPAGE_PTISO
REQUEST HB_LANG_PT

//Para gerar as credencias pelo google vá ao site:
//https://cloud.google.com/?hl=pt-br
//1-Click sobre a palavra CONSOLE no canto superior direito
//2-Faz o login com seu_email@gmail.com
//3-Barra lateral esquerda, posicione sobre "Apis e Servicos" e
//  seleciona "Credenciais" no sub menu.
//4-Crie uma credencial para seu projeto
//5-faça donwload do arquivo .json
//copie o "Id do Cliente" em oDrive:cClientId
//copie a "Chave Secreta do Cliente" para oDrive:cSecretId

Static cKeySecret := "Hbpq8imdPdvApiQtbd5wysAY"                                                  // chave oasys
Static cClientId  := "123567890123-07vbq15j2gm4kalevad82jqcpg4ma8kp.apps.googleusercontent.com"  // id oasys
Static oDrive         

//----------------------------------------------------------------------------//
Function Main()
   HB_CDPSELECT("PTISO")
   //OU HB_SetCodePage("PTISO") // para ordenacion - requiere codepage.lib
   SET CENTURY ON

   UploadMyFile()
Return nil
//----------------------------------------------------------------------------//

Function UploadMyFile()
   local cFile  := ""
   local lSw    := .F.

   cFile := cGetFile32( "All Files (*.*) |*.*|", "Select a File to Upload" )
   MsgStop(cFile)
   if !Empty( cFile )
      oDrive  := TGDrive():New( , .T., .F. )
      //credenciais geradas pelo google
      oDrive:cJSonFile := "c:\fwh\samples\client_oasys.json"
      oDrive:cClientId := cClientId
      oDrive:cSecretid := cKeySecret

      //
      lSw     := oDrive:Activate()

      XBrowse(oDrive)

      if lSw
         if oDrive:Authorize()
            oDrive:ListFiles()  //carrega aFilesLists
            XBrowse( oDrive:aFilesLists )
            If oDrive:UpLoadFileG( cFile, , .T. )   // Last parameter .T., create shared link
               MsgInfo("Arquivo enviado com sucesso !!!","UpLoad")
            Else
               MsgStop(oDrive:cError,"UpLoad")
            Endif
         endif
      else
         MsgStop("Erro ao autenticar as credenciais do Google.","UpLoad")
      endif
   endif
Return nil

 

 

 


┌────────────────────────────────────────────────────────────────────────────┐
│ FiveWin for xHarbour 18.02 - Feb. 2018          xHarbour development power │▄
│ (c) FiveTech 1993-2018 for Microsoft Windows 9X/NT/200X/ME/XP/Vista/7/8/10 │█
└────────────────────────────────────────────────────────────────────────────┘█
  ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
Compiling...
xHarbour 1.2.3 Intl. (SimpLex) (Build 20180311)
Copyright 1999-2018, http://www.xharbour.org http://www.harbour-project.org/
Compiling 'oagmail.prg' and generating preprocessed output to 'oagmail.ppo'...
Generating C source output to 'oagmail.c'...
Done.
Lines 69, Functions/Procedures 3, pCodes 153
Embarcadero C++ 7.30 for Win32 Copyright (c) 1993-2017 Embarcadero Technologies,
 Inc.
oagmail.c:
Turbo Incremental Link 6.80 Copyright (c) 1997-2017 Embarcadero Technologies, In
c.
Error: Unresolved external '_HB_FUN___CLSLOCKDEF' referenced from C:\FWH\LIB\GOO
GLE.LIB|Tgdrive
Error: Unresolved external '_HB_FUN___CLSUNLOCKDEF' referenced from C:\FWH\LIB\G
OOGLE.LIB|Tgoogle
Error: Unresolved external '_HB_FUN_HB_HHASKEY' referenced from C:\FWH\LIB\GOOGL
E.LIB|Tgoogle
Error: Unresolved external '_HB_FUN_FW_GT' referenced from C:\FWH\LIB\GOOGLE.LIB
|Tgoogle
Error: Unresolved external '_HB_FUN___HBEXTERN__HBSSL__' referenced from C:\FWH\
LIB\GOOGLE.LIB|Tgoogle
Error: Unable to perform link
* Linking errors *

C:\FWH\samples>

 

Só funciona com o Harbour.

Link to comment
Share on other sites

-Segundo CNavarro pretende disponibilizar para xHarbour, não conheço quanto a outras possibilidades para xhb via código.

Como sugestão pode fazer exe no HB32, e através do comando RUN no xHarbour invocar o exe para enviar o arquivo.

Link to comment
Share on other sites

 

Necesito a alguien que lo pruebe en xHarbour antes de publicarlo

https://bitbucket.org/fivetech/fivewin-contributions/downloads/Googlex.lib

 

Linking: Gdrive.exe...
Error: Unresolved external '_HB_FUN___HBEXTERN__HBSSL__' referenced from C:\USERS\SILVA\DOWNLOADS\GOOGLEX.LIB|TGOOGLE
Error: Unresolved external '_HB_FUN_HB_MEMOREAD' referenced from C:\USERS\SILVA\DOWNLOADS\GOOGLEX.LIB|APIGFUNC
Error: Unresolved external '_HB_FUN_HB_DEFAULTVALUE' referenced from C:\USERS\SILVA\DOWNLOADS\GOOGLEX.LIB|APIGFUNC
Error: Unresolved external '_HB_FUN_HB_HHASKEY' referenced from C:\USERS\SILVA\DOWNLOADS\GOOGLEX.LIB|TGDRIVE
Error: Unable to perform link
0 Files, 0 Warnings, 5 Errors
Compile time: 0.00s   Link time: 1.66s   Total time: 1.66s
 

Link to comment
Share on other sites

Compiling: gd.prg...
Linking: Gdrive.exe...
Error: Unresolved external '_HB_FUN_HB_DEFAULTVALUE' referenced from C:\USERS\SILVA\DOWNLOADS\GOOGLEX (1).LIB|APIGFUNC
Error: Unresolved external '_HB_FUN_HB_MEMOREAD' referenced from C:\USERS\SILVA\DOWNLOADS\GOOGLEX (1).LIB|TGOOGLE
Error: Unable to perform link
1 Files, 0 Warnings, 3 Errors
Compile time: 1.79s   Link time: 3.02s   Total time: 4.82s
 

No xHarbour, Default() e MemoRead().

Obrigado!

 

 

 

Link to comment
Share on other sites

 

Qué raro, un momento que subo otra version

Intenta ahora

https://bitbucket.org/fivetech/fivewin-contributions/downloads/Googlex.lib

 

Linking: Gdrive.exe...
Error: Unresolved external '_HB_FUN_HB_DEFAULTVALUE' referenced from C:\USERS\SILVA\DOWNLOADS\GOOGLEX (2).LIB|APIGFUNC
Error: Unable to perform link
0 Files, 0 Warnings, 2 Errors
Compile time: 0.00s   Link time: 3.98s   Total time: 4.00s
 

Link to comment
Share on other sites


Acho que é assim:

FUNCTION Teste1(nValor) // Harbour
   nValor:= hb_defaultValue(nValor, Date())                                 
RETURN nValor 
 
FUNCTION Teste2(nValor) // xharbour
   hb_Default(@nValor, Date())             
RETURN nValor

Link to comment
Share on other sites

 

Disculpa, ahora si, he cambiado el comando DEFAULT, pero no habia visto esa function

Prueba ahora

https://bitbucket.org/fivetech/fivewin-contributions/downloads/Googlex.lib

Vuelve a descargarlo, me equivoqué de fichero

 

Compiling: gd.prg...
Linking: Gdrive.exe...
Error: Unresolved external '_HB_FUN_HB_DEFAULT' referenced from C:\USERS\SILVA\DOWNLOADS\GOOGLEX (3).LIB|APIGFUNC
Error: Unable to perform link
1 Files, 0 Warnings, 2 Errors
Compile time: 1.59s   Link time: 4.49s   Total time: 6.08s
 

Fiz um teste e verifiquei que as funções Default() e HB_Default() funcionam perfeitamente no Harbour 3.2. Já no xHarbour funciona somente a Default()

Portanto, Sr. Poderá usar somente a função DEFAULT() no projeto Google.lib que vai atender a ambas linguagens.

Ok!

 

Link to comment
Share on other sites

 

Compiling: gd.prg...
Linking: Gdrive.exe...
1 Files, 0 Warnings, 0 Errors
Compile time: 6.22s   Link time: 13.55s   Total time: 19.78s
Compilou e criou o executável!!:)

Ao executar:

-------------------- Internal Error Handling Information  ---------------------

Subsystem Call ....: BASE
System Code .......: 1123
Default Status ....: .F.
Description .......: Argument error
Operation .........: HHASKEY
Arguments .........:  [ 1] = Type: N Val:          1 [ 2] = Type: C Val: installed
Involved File .....: 
Dos Error Code ....: 0

 Trace Through:
----------------
HHASKEY               :       0 in Module: 
TGDRIVE:GETTOKENS     :     371 in Module: .\source\internal\TGOOGLE.PRG
TGDRIVE:ACTIVATE      :     226 in Module: .\source\internal\TGOOGLE.PRG
UPLOADMYFILE          :      70 in Module: gd.prg
MAIN                  :      37 in Module: gd.prg


############################## Video Screen Dump ##############################
Error BASE/1123  Argument error: HHASKEY Arguments: ( [ 1] = Type: N Val:  1 [ 2] = Type: C Val: installed) (Quit)  
Error BASE/1123  Argument error: HHASKEY Arguments: ( [ 1] = Type: N Val:  1 [ 2] = Type: C Val: installed)
Error at ...: HHASKEY(0) in Module:                                             |
Called from : TGDRIVE:GETTOKENS(371) in Module: .\source\internal\TGOOGLE.PRG   |
Called from : TGDRIVE:ACTIVATE(226) in Module: .\source\internal\TGOOGLE.PRG    |
Called from : UPLOADMYFILE(70) in Module: gd.prg                                |
 

Linha 70 do arquivo gd.prg

 lSw     := oDrive:Activate()

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...