Page 1 of 3

Consulta Para Antonio Linares (Mensaje a Wathsapp)

PostPosted: Wed Apr 24, 2019 3:44 pm
by ozono1981
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

Re: Consulta Para Antonio Linares (Mensaje a Wathsapp)

PostPosted: Wed Apr 24, 2019 7:57 pm
by FiveWiDi
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.

Re: Consulta Para Antonio Linares (Mensaje a Wathsapp)

PostPosted: Mon Apr 29, 2019 5:29 pm
by cnavarro
En alguna ocasión he oído hablar de http://www.apiwha.com/

Re: Consulta Para Antonio Linares (Mensaje a Wathsapp)

PostPosted: Sun May 05, 2019 9:39 pm
by Silvio.Falconi
do u Know How run it ?

Re: Consulta Para Antonio Linares (Mensaje a Wathsapp)

PostPosted: Tue May 07, 2019 5:44 pm
by jnavas
Code: Select all  Expand view

#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



 

Re: Consulta Para Antonio Linares (Mensaje a Wathsapp)

PostPosted: Tue May 07, 2019 8:59 pm
by Xevi
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!!!

Re: Consulta Para Antonio Linares (Mensaje a Wathsapp)

PostPosted: Fri Jun 07, 2019 5:25 pm
by cwanderlei_cardoso
Linares essa classe funciona? e se funciona, como que é?

Re: Consulta Para Antonio Linares (Mensaje a Wathsapp)

PostPosted: Sat Jun 08, 2019 8:03 am
by Antonio Linares
El API de whatsapp ha cambiado varias veces, luego no se si funciona ó no

A ver que comentan otros usuarios

Re: Consulta Para Antonio Linares (Mensaje a Wathsapp)

PostPosted: Sun Jun 09, 2019 8:47 am
by jvtecheto
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

Re: Consulta Para Antonio Linares (Mensaje a Wathsapp)

PostPosted: Sun Jun 09, 2019 9:32 pm
by Marcelo Roggeri
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

Re: Consulta Para Antonio Linares (Mensaje a Wathsapp)

PostPosted: Tue Jun 11, 2019 6:44 pm
by Sistem
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

Re: Consulta Para Antonio Linares (Mensaje a Wathsapp)

PostPosted: Tue Jun 11, 2019 9:05 pm
by Sistem
usando o proprio whatsapp
Code: Select all  Expand view
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

Re: Consulta Para Antonio Linares (Mensaje a Wathsapp)

PostPosted: Tue Jun 11, 2019 10:46 pm
by Marcelo Roggeri
Hola gracias por compartir el código, para que Chrome quede oculto como haces? se puede?
Saludos
Marcelo

Re: Consulta Para Antonio Linares (Mensaje a Wathsapp)

PostPosted: Wed Jun 12, 2019 8:43 am
by Silvio.Falconi
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 )

Re: Consulta Para Antonio Linares (Mensaje a Wathsapp)

PostPosted: Wed Jun 12, 2019 9:06 am
by Sistem
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