WhatsApp Messaging from Web

If you need to send WhatsApp message to your friend from Web, you need to find unofficial API as WhatsApp till date do not provide them, and do not allow bulk messaging as well. But in one of my project, I need to send message on whatsapp, for those who subscribe on website to recieve those about our service updates. So, I use WhatsApi (https://github.com/venomous0x/WhatsAPI New URL is https://github.com/WHAnonymous/Chat-API ), simply because it was most recommended API I found. I didn’t even try any other API code, as it works like charm for me. It has AjaxDemo folder in there, with 3 files. Anyone can easily learn the coding from it. So, I don’t go in much of coding part in this article. But here is basic steps with some code. To start with,

  • You will need a Mobile number that will be used to send messages. Make sure that you can recieve SMS on this mobile phone to verify the Whatsapp account.
  • Once you have your phone ready, download WART (https://github.com/shirioko/WART) which provide a simple EXE, to enter your phone and get a Password for API. Remember Whatsapp send password once every 30 minute, so if you want to get new password you have to wait 30 minutes. This step is no longer required as API has registration function available. Please refer API documentation for it.
  • Now, that you have WhatsAPP mobile phone and password, simply try this code.


require_once 'whatsprot.class.php';
$username = "11111111111"; //Mobile Phone prefixed with country code so for india it will be 91xxxxxxxx
$password = "somepasswordstring";

$w = new WhatsProt($username, 0, "WhatsApp Messaging", true); //Name your application by replacing "WhatsApp Messaging"

$target = '912222222222'; //Target Phone,reciever phone
$message = 'Your message comes here';

$w->SendPresenceSubscription($target); //Let us first send presence to user
$w->sendMessage($target,$message ); // Send Message

Yes, it was that simple. You can send Image and Video as well, but I am not going to explain them here, though to send Media you need to call ‘$w->pollMessages()’ otherwise your message won’t be sent. Note: all Phone must prefix the country code or it won’t send messages. To send media, you can either give Physical path or a URL to media resource.   EDIT: The API is now moved to new location: https://github.com/mgp25/Chat-API


80 responses to “WhatsApp Messaging from Web”

  1. Thanks, This is helpful post.

    How to know mobile number is registered or not in whatsapp.

    I have using Whatsapp API for PHP

  2. Use Contact Sync method within library. It will add the valid phone number in your number’s contact book, and give a list of invalid phone or phone that do not exist/use whatsapp. You should always use Contact sync at time of login to ensure you do not spam or misuse it.

  3. Hi, Hope you are doing Good. I am also using WART to register user everything is going on smooth but when i am sending message after sending 20 to 23 messages my number is getting blocked using this API can u please how to handle this ( I am also send typing,Sync and presence through code can you tell me how u r using to send unlimited message from this API


  4. First thing, the above script is just for educational purpose so I remember the code. And It should not be used for mass messaging, unless you are authorize to do that by Whatsapp.

    Now, if you are doing mass messaging then you are lucky to send 20-23 messages. Usually it block user in just 5 message. The script above do not prevent it at any cost. It is just basic script that send message. Period.

    There is lot of discussion how we avoid getting blocked during mass message. Well there is no fixed answer to topic. It is hit and trial for most, but the sequence below might help.

    1. Login
    2. Sync Contact
    3. Poll Messages
    4. SendTyping add wait for couple of seconds.
    5. Send Finish Typing.
    6. Send Message/Video/Photo.
    7. Poll Message. wait for 10-15 second before next message.

    8. Repeat it for couple of messages,
    9. Let the script die.
    10. Run other instance, Login again..

    Since logout doesn’t work for me, I let the script die and run it again through cron/Scheduler. It is going to be very slow to run just once script for messaging and using just single SIM. you must use lot of them and randomize the sender sim to avoid been marked as SPAM Sender and getting blocked.

    • Hi ,
      Please Can you explain How to make these Steps by whatsApi

      > 4. SendTyping add wait for couple of seconds.
      > 5. Send Finish Typing.


    • It is as simple as:

      $w->sendMessage($target, $message);

  5. Hi Sumit,
    Appreciate your effort I am following the same procedure mentioned by you. I have also try to use interactive session in the process but its also gets fail my motive is send mass message in one go


    • As I mention in previous message, bulk messages will not help you. You have to “show” as if it is used naturally, and that can only be done by time delay and break-up between complete send. Also, make sure you message only to number that are using whatsapp, if you send to numbers that won’t it will block you. Sync Contact gives you details of numbers.

  6. Hi, can this be used theoretically to receive whatsapp msgs without the SIM card/phone presence?

    assuming of course I can receive the SMS authorization number.



  7. hi, i have tested this source code and i have tried send only 1 message and whatsapp has blocked my account.

    Anyone can help me? i have already sent an email to whatsapp support but no response…

  8. Hii.. i am using this script but “Parse error: parse error in D:\xampp\htdocs\script\whatsapp\src\whatsprot.class.php on line 108 ” This error show..plz help..plz

    • Maybe you download latest build or you are running old version of PHP. Please check with original developer. I just use those script, I didn’t originally wrote them.

  9. Yes its working now…But when i am using “Ajaxdemo” then msg not sent….Any iDea sir about this

  10. i send 30 message from different-different number & psswords but now showing login faliure…… What is this..???

  11. I tried to do these several times , but it wasn’t successful , Can you explain it more ? Thank you .

  12. Hi. I am trying to find a library for windows that can receive whatsapp messages. I have seen the Python and the PHP but no DLLs. Do u know if this PHP can be turn into a windows library so i can use VBScript to check for new messages? it is for an internal monitoring of devices at a facility…

    Any comment will be appreciated. Thanks!

  13. How i Get a Profile Pic Of Particular User

    The Method is Present in File But its Not Working
    Please Help

    • Not sure which script or demo you are referring, but ajaxDemo folder has implementation of getProfilePicture event, I suggest you take a look there.

  14. Hi, I could send the plain text to any number. But problem is if I send http://www.google.com. It is not coming with heperlink format, means in clickable format. Can you please tell how I can achieve it. I tried all options, but failed.

  15. i was using this,and its working fine now i am not able to snd images n other media,and also at time to making group this mesage arraives

    rx rx

  16. Its not working now, the Wart tool is not able to send the verification code is there any other registration tools available which would work now on updated whatsapp ?

    • Well not sure. But if you are not getting the code it means WhatsApp server is having problem connecting your mobile operator or something. Also WhatsApp provide new password every 30 minutes, so if you are over trying it you might not get pass code. Try after break.

  17. Why each and every message from Indians is a crying message? Come on dude, read, try, learn and do it. Stop asking and asking just because.

  18. dear sumit
    i am also facing same problem from few days. can you please tell me how i can register on whatsapp. before that i have registered my 3 numbers on whatsapi. now i am unable to recieve sms code.
    i tried from wart, yowsup, and whatsapi gateways to request code. but i failed to request code

  19. Hola, aún se pueden enviar mensajes desde php utilizando whatsapi, ya que para olfatear la contraseña con los programas que se comentan desde el post no funcionan.
    ¿Qué pasa?, ¿a caso el modo de autentificación de cuentas en whatsapp es el problema?.

  20. Hi –

    Array ( [method] => sms [in] => ************ [cc] => ** [id] => %b6x%9f%c6%ab%0d%c8%2c%f1+%99%d1%c2%d4%0a%b9%94%e8a%0c [lg] => en [lc] => PK [token] => JV4e1LQAruas6AxzePh%2BcLeVxa0%3D [sim_mcc] => 000 [sim_mnc] => 000 ) stdClass Object ( [status] => fail [reason] => old_version )

    Getting error while requesting code. On Wart and also using php function.

    Thanks for help in advance.

    • please use forum(s) to ask “the errors like this”, also the error you past clearly shows the reason of its failure, and since I am not developer of api or wart, I suggest to ask them after you check which version you are using. hoping you are using latest version of api.

  21. I see this error when i register my mobile number through api.

    Array ( [method] => voice [in] => 9461248574 [cc] => 91 [id] => %d7%cc%7f%d7%27%dd%00%7d%91sc%2a%0b0o%3b%d1i%ccq [lg] => hi [lc] => IN [token] => 1jm2TXyXyyswER7v6YzNpW3DZDI%3D [sim_mcc] => 000 [sim_mnc] => 000 ) stdClass Object ( [status] => fail [reason] => old_version )

  22. HI Sumit,

    Could you please explain how do i register with WART. When i am tried with WART it shows below message
    ” Could not request code using either sms or voice”,

    Kindly advice me.

    • No sure of mac version, but you can try alternative i.e if you know PHP WhatsAPI support Registration and you can use that to register. WART is .net based application, if you have parallel VM then you can use it.

  23. I have a problem as I generate a password watsapp reset watsapp immediate and after that I getting anauthorize error
    Please help me

    • whatsapp never automatically reset password. You surely are using the same mobile number somewhere else like your device and while you set password in code your mobile device might be setting new password as well and hence the problem. Do not use the that number for whatsapp on device or do not set it multiple times.

  24. HI. when i execute send. i also received all incoming wa messages. how to solved it ? because i want to separate code between sending and receiving messages ?

    • You can ignore incoming message, but you cannot avoid them. WhatsAPP like anyother chat system is two way traffic, you cannot stop one way on your desire. And once you miss a message from saving (if you want to) the you miss it forever, you cannot get it back from incoming stream.

  25. Hello, how can i know if some number has whatsapp installed or it is registered, i was reading that you can do that by using sync contacts, but i dont understand what method to use, do you guys know somehting about this ? please.

  26. Hello, I have used your code; but it shows exception with message “Login Failure”. I have password for my whats app account but still it shows exception. Please help asap. Thanks..

  27. I have check with git hub url given in blog, but when I accessing that link it shows an empty directory or the user not found, can please share library files or update the current link which it is available. Thanks in advance.

  28. Hi, i did the test and get below error

    PHP Fatal error: Uncaught exception ‘LoginFailureException’ in /var/www/html/Chat-API-master/src/whatsprot.class.php:2235

    please helop to test it successfully ….

  29. How we check the GroupsParticipants of the group this function is not available sendGetGroupsParticipants($gjid) please help me

    • Hi Sumit,

      I registered my test mobile using WART and got the password.

      Now when I try to use it in the message sender file as:


      $target = ‘919028093321’; //Target Phone,reciever phone
      $message = ‘Tets Message.’;

      $w->SendPresenceSubscription($target); //Let us first send presence to user
      $w->sendMessage($target, $message);


      It gives me an error like:

      PHP Parse error: syntax error, unexpected ‘[‘ in /var/www/html/Chat-API-master/src/whatsprot.class.php on line 43

      I run the php file on the command line.

      Can you suggest what may be wrong?

      Thanks in advance.

    • No, it will reset the password and then your phone app is not able to login. If you reinstall it will reset password again and then your API won’t login. To make it login, you need to extract the password from Phone memory, which I don’t know how to do. Even if you do so, you will end up getting blocked as getting too many password change or device change with same password will trigger their anti spam.