Whatsapp

How to send whatsapp message using PHP?

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/mgp25/WhatsAPI-Official), 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.
  • Now, that you have WhatsAPP mobile phone and password, simply try this code.

 

 

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.

Otherwise download API from https://github.com/mgp25/WhatsAPI-Official and change credentials in example -> whatsapp.php

To make two way processing use ajaxdemo folder.

 

app

 

 

Check How to obtain whatsapp ID and Password Here.

Thanks!. If you like this article don’t forget to share and comment.