FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour Consulta Para Antonio Linares (Mensaje a Wathsapp)
Posts: 39
Joined: Tue Mar 26, 2013 02:09 PM
Consulta Para Antonio Linares (Mensaje a Wathsapp)
Posted: Wed Apr 24, 2019 03:44 PM

Estimado Antonio y Amigos del Foro

Llevo mucho tiempo sin contactarlos, pero con los cambios de tecnologia de tiempo en tiempo me veo en la necesidad de recurrir a su basto conocimiento.

Un cliente me solicito hacer envios de Wathsapp a varios numeros, alguien tiene algo que me pueda servir o que me oriente que camino debo seguir?

Agradecido por su enorme ayuda.

Mois茅s

Posts: 1445
Joined: Mon Oct 10, 2005 02:38 PM
Re: Consulta Para Antonio Linares (Mensaje a Wathsapp)
Posted: Wed Apr 24, 2019 07:57 PM

Y porque whatsapp?
Los bancos utilizan el SMS.
Hazlo con SMS.
Yo uso http://www.smsarena.es ... y va de 10!!!
Ahora te falta un poco de marqueting para convencer al cliente.

Un Saludo

Carlos G.



FiveWin 25.12 + Harbour 3.2.0dev (r2502110321), BCC 7.7 Windows 11 Home

Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: Consulta Para Antonio Linares (Mensaje a Wathsapp)
Posted: Mon Apr 29, 2019 05:29 PM

En alguna ocasi贸n he o铆do hablar de http://www.apiwha.com/

Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noci贸n del tiempo

El secreto de la felicidad no est谩 en hacer lo que te gusta, sino en que te guste lo que haces
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: Consulta Para Antonio Linares (Mensaje a Wathsapp)
Posted: Sun May 05, 2019 09:39 PM

do u Know How run it ?

Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 492
Joined: Wed Nov 16, 2005 12:03 PM
Re: Consulta Para Antonio Linares (Mensaje a Wathsapp)
Posted: Tue May 07, 2019 05:44 PM
Code (fw): Select all Collapse
#include "FiveWin.ch"
#include "hbsocket.ch"

function Main()

   local oWA := HB_WhatsApp():New()

   ? oWA:Connect()
   oWA:Login()

return nil

/*
cmResponse = Chr( 0x01 )+Chr( 0x31 )+Chr( 0xF8 )+Chr( 0x04 )+Chr( 0x86 )+Chr( 0xBD )+;
Chr( 0xA7 )+Chr( 0xFD )+Chr( 0 )+Chr( 0x01 )+Chr( 0x28 )    


// this packet contains the name 

cNext = Chr( 0 )+Chr( 0x12 )+Chr( 0xf8 )+Chr( 0x05 )+Chr( 0x74 )+Chr( 0xa2 )+Chr( 0xa3 )+Chr( 0x61 )+;
Chr( 0xFC )+Chr( 0x0A )+Chr( 0x41 )+Chr( 0x68 )+Chr( 0x6D )+Chr( 0x65 )+Chr( 0x64 )+Chr( 0x20 )+;
Chr( 0x4D )+Chr( 0x6F )+Chr( 0x68 )+Chr( 0x64 )+Chr( 0 )+Chr( 0x15 )+Chr( 0xF8 )+Chr( 0x06 )+;
Chr( 0x48 )+Chr( 0x43 )+Chr( 0x05 )+Chr( 0xA2 )+Chr( 0x3A )+Chr( 0xF8 )+Chr( 0x01 )+Chr( 0xF8 )+;
Chr( 0x04 )+Chr( 0x7B )+Chr( 0xBD )+Chr( 0x4D )+Chr( 0xF8 )+Chr( 0x01 )+Chr( 0xF8 )+Chr( 0x03 )+;
Chr( 0x55 )+Chr( 0x61 )+Chr( 0x24 )+Chr( 0 )+Chr( 0x12 )+Chr( 0xF8 )+Chr( 0x08 )+Chr( 0x48 )+Chr( 0x43 )+;
Chr( 0xFC )+Chr( 0x01 )+Chr( 0x32 )+Chr( 0xA2 )+Chr( 0x3A )+Chr( 0xA0 )+Chr( 0x8A )+Chr( 0xF8 )+Chr( 0x01 )+;
Chr( 0xF8 )+Chr( 0x03 )+Chr( 0x1F )+Chr( 0xBD )+Chr( 0xB1 )
*/

CLASS HB_WhatsApp

   DATA  pSocket
   DATA  cHost  INIT "bin-short.whatsapp.net"
   DATA  nPort  INIT 5222
   DATA  cIP
   DATA  aResArray
   DATA  cMsg
   DATA  _Incomplete_message

   METHOD New()
   METHOD Connect()
   METHOD Login()
   
   METHOD Read()
   METHOD Send( cData )

   METHOD _Identify( cStr )
   METHOD _Is_Full_Msg( cStr )

   DESTRUCTOR Destroy()

ENDCLASS

METHOD New() CLASS HB_WhatsApp

   ::cIP = hb_socketGetHosts( ::cHost )[ 1 ]
   ::pSocket = hb_socketOpen()

return self

METHOD Connect() CLASS HB_WhatsApp

return hb_socketConnect( ::pSocket, { HB_SOCKET_AF_INET, ::cIP, ::nPort } )

static function StrToHex( cStr )

   local n, cHex := "" 
   
   for n = 1 to Len( cStr )
      cHex += "0x" + hb_NumToHex( Asc( SubStr( cStr, n, 1 ) ) )
      if n < Len( cStr )
         cHex += ", "
      endif   
   next
   
return cHex         

static function random_uuid()

return hb_strformat( "%04x%04x-%04x-%04x-%04x-%04x%04x%04x",;
                     hb_Random( 0, 0xffff ), hb_Random( 0, 0xffff ),;
                     hb_Random( 0, 0xffff ),;
                     hb_BitOr( hb_Random( 0, 0x0fff ), 0x4000 ),;
                     hb_BitOr( hb_Random( 0, 0x3fff ), 0x8000 ),;
                     hb_Random( 0, 0xffff ), hb_Random( 0, 0xffff ), hb_Random( 0, 0xffff ) )
              
METHOD Login() CLASS HB_WhatsApp

   local cBuffer, cResponse

   ? ::Send( "WA" + Chr( 0x01 ) + Chr( 0 ) + Chr( 0 ) + ;
             Chr( 0x19 ) + Chr( 0xF8 ) + Chr( 0x05 ) + Chr( 0x01 ) + ;
             Chr( 0xA0 ) + Chr( 0x8A ) + Chr( 0x84 ) + Chr( 0xFC ) + ;
             Chr( 0x11 ) + "iPhone-2.6.9-5222" + ;
             Chr( 0 ) + Chr( 0x08 ) + Chr( 0xF8 ) + Chr( 0x02 ) + ;
             Chr( 0x96 ) + Chr( 0xF8 ) + Chr( 0x01 ) + Chr( 0xF8 ) + ;
             Chr( 0x01 ) + Chr( 0x7E ) + Chr( 0 ) + Chr( 0x07 ) + Chr( 0xF8 ) + ;
             Chr( 0x05 ) + Chr( 0x0F ) + Chr( 0x5A ) + Chr( 0x2A ) + ;
             Chr( 0xBD ) + Chr( 0xA7 ) )

   cBuffer = ::Read()
   cResponse = hb_base64decode( SubStr( cBuffer, 27 ) )

   ? cResponse
   ? random_uuid()

return nil

METHOD Read() CLASS HB_WhatsApp

   local cBuffer := Space( 1024 ), cV, cRcvdType
   local nLen := hb_socketRecv( ::pSocket, @cBuffer )

   cBuffer = SubStr( cBuffer, 1, nLen )
   ::aResArray = HB_ATokens( cBuffer, Chr( 0 ) )
   // ? StrToHex( cBuffer )
   
   for each cV in ::aResArray 
      cRcvdType = ::_Identify( cV ) 

      // ? cRcvdType
      // ? StrToHex( cV )

      do case
         case cRcvdType == "incomplete_msg"
              ::_incomplete_message = cV

         case cRcvdType == "msg"
              ::cMsg = ::parse_received_message( cV )
         
         case cRcvdType == "account_info"
              ::accinfo = ::parse_account_info( cV )

         case cRcvdType == "last_seen"
              ::lastseen = ::parse_last_seen( cV )
      endcase
   next

return cBuffer

METHOD Send( cData ) CLASS HB_WhatsApp

return hb_socketSend( ::pSocket, cData )

static function StartsWith( cStr, cCompare, nPos )

return SubStr( cStr, nPos, Len( cCompare ) ) == cCompare

static function EndsWith( cStr, cCompare )

return Right( cStr, Len( cCompare ) ) == cCompare

METHOD _Identify( cStr ) CLASS HB_WhatsApp

   local cMsg_identifier := Chr( 0x5D ) + Chr( 0x38 ) + Chr( 0xFA ) + Chr( 0xFC ) 
   local cServer_delivery_identifier := Chr( 0x8C ) 
   local cClient_delivery_identifier := Chr( 0x7F ) + Chr( 0xBD ) + Chr( 0xAD )
   local cAcc_info_iden := Chr( 0x99 ) + Chr( 0xBD ) + Chr( 0xA7 ) + Chr( 0x94 )    
   local cLast_seen_ident := Chr( 0x48 ) + Chr( 0x38 ) + Chr( 0xFA ) + Chr( 0xFC )
   local cLast_seen_ident2 := Chr( 0x7B ) + Chr( 0xBD ) + Chr( 0x4C ) + Chr( 0x8B )

   if ! ::_is_full_msg( cStr )
      return "incomplete_msg"

   elseif StartsWith( cStr, cMsg_identifier, 3 )

      if EndsWith( cStr, cServer_delivery_identifier )
         return "server_delivery_report"

      elseif EndsWith( cStr, cClient_delivery_identifier ) 
         return "client_delivery_report"

      else
         return "msg"

      endif 

   elseif StartsWith( cStr, cAcc_info_iden, 3 )
      return "account_info"

   elseif StartsWith( cStr, cLast_seen_ident, 3 ) .and. cLast_seen_ident2 $ cStr
      return "last_seen"
   
   else
      return "other"

   endif

return nil

METHOD _Is_Full_Msg( cStr ) CLASS HB_WhatsApp

return Len( cStr ) == Asc( Left( cStr, 1 ) ) + 1

METHOD Destroy() CLASS HB_WhatsApp

   HB_SocketShutDown( ::pSocket )
   HB_SocketClose( ::pSocket )

   ::pSocket = nil

return nil
Posts: 174
Joined: Wed Nov 29, 2017 11:42 AM
Re: Consulta Para Antonio Linares (Mensaje a Wathsapp)
Posted: Tue May 07, 2019 08:59 PM

Este c贸digo / classe, compila y se ejecuta. Muestra unos Alerts, pero no veo como utilizarlo en la pr谩ctica.

De poder mandar mensajes de Whatsapp desde Harbour... seria un lujazo!!!

Un Saludo,

Xevi.



Aprendiz de la vida!!!
Posts: 5
Joined: Mon May 20, 2019 03:49 PM
Re: Consulta Para Antonio Linares (Mensaje a Wathsapp)
Posted: Fri Jun 07, 2019 05:25 PM

Linares essa classe funciona? e se funciona, como que 茅?

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Consulta Para Antonio Linares (Mensaje a Wathsapp)
Posted: Sat Jun 08, 2019 08:03 AM

El API de whatsapp ha cambiado varias veces, luego no se si funciona 贸 no

A ver que comentan otros usuarios

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 607
Joined: Mon Mar 04, 2013 04:32 PM
Re: Consulta Para Antonio Linares (Mensaje a Wathsapp)
Posted: Sun Jun 09, 2019 08:47 AM
Antonio Linares wrote:El API de whatsapp ha cambiado varias veces, luego no se si funciona 贸 no

A ver que comentan otros usuarios
Hola.

Yo tambi茅n compile la clase y no da errores. Veo que es de Juan Nav脿s con el cual nos cruzamos correos hace muchoooooss a帽os y es un gran programador, seguro que si tiene un rato nos aclarara el asunto.

Ser铆a una aportaci贸n fant谩stica.

Jos茅

Enviado desde mi ONE A2003 mediante Tapatalk
Fwh 24.07 64 bits + Harbour 64 bits 3.2dev(r2407221137) + MSVC64
Posts: 344
Joined: Sat Jul 22, 2006 09:04 PM
Re: Consulta Para Antonio Linares (Mensaje a Wathsapp)
Posted: Sun Jun 09, 2019 09:32 PM

Hola buenas tardes, yo la he compilado y al ejecutar da unos mensajes : el primero .T. el segundo 50 el tercero vac铆o y el ultimo un conjunto de n煤meros y letras.
Tambi茅n me interesa.
Saludos

FWH - Harbour - BCC7 - PellesC
Posts: 226
Joined: Sun May 13, 2012 07:52 AM
Re: Consulta Para Antonio Linares (Mensaje a Wathsapp)
Posted: Tue Jun 11, 2019 06:44 PM

tem que loga na whatsappWEB

for x=1 to 10
Whatsapp("85999999999", "859999904"+strzero(x,2), "msg teste"+strzero(x,2))
next
*--------------------------------------------------------------------------------
Function Whatsapp(cDe, cPara, cmsg)
Local clink := "wppredirect.tk/go/?p=55"+cPara+"&m=Envio"+cDe // 55 brasil

oShell := CreateObject( "WScript.Shell" )
oShell:run(uRegPath+"\chrome\chrome.exe "+clink )
syswait(5)
oShell:SendKeys("~")
syswait(2)
oShell:SendKeys("Ola mundo")
oShell:SendKeys("~")
syswait(2)
oShell:SendKeys(cMsg)
oShell:SendKeys("~")

Return nil

FWH2008 | xHarbour | BCC74 | SQLRDD
Posts: 226
Joined: Sun May 13, 2012 07:52 AM
Re: Consulta Para Antonio Linares (Mensaje a Wathsapp)
Posted: Tue Jun 11, 2019 09:05 PM
usando o proprio whatsapp
Code (fw): Select all Collapse
for x=1 to 10
    Whatsapp("85999999999", "859999904"+strzero(x,2), "msg teste"+strzero(x,2))
next

*--------------------------------------------------------------------------------
Function Whatsapp(cDe, cPara, cmsg)
Local clink := "https://api.whatsapp.com/send?phone=55"+cPara+"&text="+cmsg

   oShell := CreateObject( "WScript.Shell" )
   oShell:run(uRegPath+"\chrome\chrome.exe "+clink)
   syswait(2)
   oShell:sendkeys("{tab}")
   syswait(2)
   oShell:sendkeys("{tab}")
   syswait(2)
   oShell:SendKeys("~")
   syswait(5)
   oShell:sendkeys("ola, *"+cPara+"* essa e uma mensagem automatica")
   oShell:SendKeys("~")
   syswait(3)
   oShell:SendKeys(cMsg)
   oShell:SendKeys("~")
   syswait(3)
   oShell:SendKeys("~")
Return nil
FWH2008 | xHarbour | BCC74 | SQLRDD
Posts: 344
Joined: Sat Jul 22, 2006 09:04 PM
Re: Consulta Para Antonio Linares (Mensaje a Wathsapp)
Posted: Tue Jun 11, 2019 10:46 PM

Hola gracias por compartir el c贸digo, para que Chrome quede oculto como haces? se puede?
Saludos
Marcelo

FWH - Harbour - BCC7 - PellesC
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: Consulta Para Antonio Linares (Mensaje a Wathsapp)
Posted: Wed Jun 12, 2019 08:43 AM

Application

Path and name: C:\Work\Errori\whatup\test.Exe (32 bits)
Size: 3,795,456 bytes
Compiler version: Harbour 3.2.0dev (r1712141320)
FiveWin version: FWH 19.03
C compiler version: Borland/Embarcadero C++ 7.3 (32-bit)
Windows version: 6.1, Build 7601 Service Pack 1

Time from start: 0 hours 0 mins 0 secs
Error occurred at: 06/12/19, 10:42:46
Error description: (DOS Error -2147352567) WINOLE/1007 (0x80070002): RUN
Args:
[ 1] = C C:\Program Files (x86)\Google\chrome\chrome.exe https://api.whatsapp.com/send?phone=553 ... 1&text=msg teste01

Stack Calls

Called from: => TOLEAUTO:RUN( 0 )
Called from: test.prg => WHATSAPP( 32 )
Called from: test.prg => TEST( 19 )

Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 226
Joined: Sun May 13, 2012 07:52 AM
Re: Consulta Para Antonio Linares (Mensaje a Wathsapp)
Posted: Wed Jun 12, 2019 09:06 AM
Marcelo Roggeri wrote:Hola gracias por compartir el c贸digo, para que Chrome quede oculto como haces? se puede?
Saludos
Marcelo

oShell:run("chrome.exe "+clink, 0) // tenta 0
FWH2008 | xHarbour | BCC74 | SQLRDD