Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

tests/whatsapp.php Send message does not work but interactive works! #177

Open
xxxazxxx opened this Issue · 6 comments

3 participants

@xxxazxxx

does not format good here, pastebin : http://www.privatepaste.com/1fb93434e7

aditya@ubuntu:~/code/wa/WhatsAPI/tests$ php whatsapp.php -s 91989236XXXX 'hi'
[] Logging in as 'WhatsAPI Test' (91900427XXXX)

tx stream:features
tx
tx /stream:features

tx

rx

rx stream:features
rx
rx /stream:features

rx {�g���� |Y�X�QȮW�|

tx ��P���t���jA�1�G~�������K�������;�b����_�|�n

rx �8?�B 0l�)��r�H�<�ڵ

[] Request last seen 91989236XXXX: PHP Warning: Missing argument 2 for WhatsProt::RequestLastSeen(), called in /WhatsAPI/tests/whatsapp.php on line 104 and defined in /WhatsAPI/src/php/whatsprot.class.php on line 345
PHP Stack trace:
PHP 1. {main}() /WhatsAPI/tests/whatsapp.php:0
PHP 2. WhatsProt->RequestLastSeen() /WhatsAPI/tests/whatsapp.php:104
PHP Notice: Undefined variable: to in /WhatsAPI/src/php/whatsprot.class.php on line 355
PHP Stack trace:
PHP 1. {main}() /WhatsAPI/tests/whatsapp.php:0
PHP 2. WhatsProt->RequestLastSeen() /WhatsAPI/tests/whatsapp.php:104

tx
tx
tx

[] Send message to 91989236XXXX: hi

tx
tx
tx
tx
tx hi
tx

@shadzik

Comment out the Request Last Seen function call at line 109:

$wa->RequestLastSeen($dst);

or fix it by replacing it with:

$wa->RequestLastSeen(time()."-1","$dst");

@guidomgs

that still not working for me :S

@shadzik

Well, it truly works for me. Even using this API in a custom script like this one works:

<?php
require "WhatsAPI/src/php/whatsprot.class.php";

$nickname = "";
$sender = ""; // Mobile number with country code (but without + or 00)
$imei = ""; // MAC Address for iOS, IMEI for other platform (Android/etc)

$countrycode = substr($sender, 0, 2);
$phonenumber=substr($sender, 2);

$dst=$_SERVER['argv'][1];
$user=$_SERVER['argv'][2];
$msg = "Hello $user";

$wa = new WhatsProt($sender, $imei, $nickname, false);
$wa->Connect();
$wa->Login();
$wa->Message(time()."-1", $dst , $msg);
?>

As you can see, I don't bother using RequestLastSeen(). Works like a charm.
I guess it won't work when you register your device with WA 2.8.6 for iPhone. This version uses a different password generation algorithm than 2.8.4 and older. AFAIK 2.8.6 is not backwards compatible with older versions, so if you registered using this version, you won't be able to use WhatsAPI. I used an older device to register with 2.8.4 and since then am using this account with WhatsAPI.

Cheers.

@guidomgs

if i use your code, the output is like this:

tx
tx
tx
tx
tx
tx
tx 549XXXXXX
tx

where the fist line instead using the number is using the message id

@guidomgs

message to="1354845605-1@s.whatsapp.net" type="chat" id="1354845605-1" t="1354845605"

@guidomgs

fixed!
after the sendmessage function call is good to add sleep(1); to let the script send the message

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.