How to send WhatsApp messages to phones using PHP
How to send WhatsApp messages to phones using PHP
Hi AppGineers,
can anyone of you tell, how to send text notifications to WhatsApp phone numbers using PHP?
I'd like to notify users about certain tasks or status changes. I can store their phone numbers in AppGini and [x] check if they want to be informed or not. It is just about notification; there is no need for processing any responses.
I have read there is no WhatsApp API any longer and it seems we need to contract with an official gateway provider like TWILIO. Can anyone please share her/his experiences.
Thanks in advance!
Regards,
Jan
can anyone of you tell, how to send text notifications to WhatsApp phone numbers using PHP?
I'd like to notify users about certain tasks or status changes. I can store their phone numbers in AppGini and [x] check if they want to be informed or not. It is just about notification; there is no need for processing any responses.
I have read there is no WhatsApp API any longer and it seems we need to contract with an official gateway provider like TWILIO. Can anyone please share her/his experiences.
Thanks in advance!
Regards,
Jan
Kind regards,
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
AppGini 24.10 Revision 1579 + all AppGini Helper tools
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
[code]...[/code]
blocks for better readabilityAppGini 24.10 Revision 1579 + all AppGini Helper tools
-
- Veteran Member
- Posts: 61
- Joined: 2017-03-12 09:24
- D Oliveira
- AppGini Super Hero
- Posts: 347
- Joined: 2018-03-04 09:30
- Location: David
Re: How to send WhatsApp messages to phones using PHP
Hey Jan, I have something that could help you, mobile version will use native whatsapp and desktop version will use whatsapp web, hope it helps =)
Code: Select all
<div>
<button onclick="share();" style="background-color:rgba(0,0,0,0.4);border-top-left-radius: 5px;border-bottom-left-radius: 5px;border-top-right-radius: 5px;border-bottom-right-radius: 5px;color:white;font-size:20px;font-family:Gotham2;border:0.1px solid black;padding: 5px 10px 7px;">
Share via Whatsapp </button>
</div>
<div>
<img src="spacer.png?c=91" style="width:100%;height:50px;">
</div>
<?php
function isMobile() {
return preg_match("/(android|avantgo|blackberry|bolt|boost|cricket|docomo|fone|hiptop|mini|mobi|palm|phone|pie|tablet|up\.browser|up\.link|webos|wos)/i", $_SERVER["HTTP_USER_AGENT"]);
}
if(isMobile()){
?>
<script>
function share(){
LinkTextToShare = 'https://api.whatsapp.com/send?text=' + encodeURIComponent(window.location.href) ;
popup_window = window.open(LinkTextToShare,"_blank");
//setInterval(function(){ popup_window.close (); }, 1000);
popup_window.close ();
}
</script>
<?php }else{
?>
<script>
function share(){
LinkTextToShare = 'https://web.whatsapp.com/send?l=en&text=' + encodeURIComponent(window.location.href) ;
popup_window = window.open(LinkTextToShare,"_blank");
}
</script>
<?php }
?>
<img src="spacer.png?c=91" style="width:100%;height:30px;">
Re: How to send WhatsApp messages to phones using PHP
Hi,G Belgrado wrote: ↑2020-05-25 16:13Hi Jan
there would be this for whatsapp API
API WhatsApp Business
but it's not free
did you manage to use it according to the docs?
I have already seen that documentation page before. They are talking about a registration, but there is not even a "login" or "register" link on the page they are refering to.
Thanks anyway!
Jan
Kind regards,
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
AppGini 24.10 Revision 1579 + all AppGini Helper tools
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
[code]...[/code]
blocks for better readabilityAppGini 24.10 Revision 1579 + all AppGini Helper tools
Re: How to send WhatsApp messages to phones using PHP
D Oliveira wrote: ↑2020-05-26 04:46Hey Jan, I have something that could help you, mobile version will use native whatsapp and desktop version will use whatsapp web, hope it helps =)
Code: Select all
<div> <button onclick="share();" style="background-color:rgba(0,0,0,0.4);border-top-left-radius: 5px;border-bottom-left-radius: 5px;border-top-right-radius: 5px;border-bottom-right-radius: 5px;color:white;font-size:20px;font-family:Gotham2;border:0.1px solid black;padding: 5px 10px 7px;"> Share via Whatsapp </button> </div> <div> <img src="spacer.png?c=91" style="width:100%;height:50px;"> </div> <?php function isMobile() { return preg_match("/(android|avantgo|blackberry|bolt|boost|cricket|docomo|fone|hiptop|mini|mobi|palm|phone|pie|tablet|up\.browser|up\.link|webos|wos)/i", $_SERVER["HTTP_USER_AGENT"]); } if(isMobile()){ ?> <script> function share(){ LinkTextToShare = 'https://api.whatsapp.com/send?text=' + encodeURIComponent(window.location.href) ; popup_window = window.open(LinkTextToShare,"_blank"); //setInterval(function(){ popup_window.close (); }, 1000); popup_window.close (); } </script> <?php }else{ ?> <script> function share(){ LinkTextToShare = 'https://web.whatsapp.com/send?l=en&text=' + encodeURIComponent(window.location.href) ; popup_window = window.open(LinkTextToShare,"_blank"); } </script> <?php } ?> <img src="spacer.png?c=91" style="width:100%;height:30px;">
Hi,
thank you. Unfortunately this is clientside Javascript which requires a WhatsApp installation or an open WhatsAppWeb-session + additional user interaction.
I am looking for a server side PHP solution which I can use for mass sending WhatsApp messages to known phone numbers without user interaction per message.
Thank you both for taking the time!
Regards,
Jan
Kind regards,
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
AppGini 24.10 Revision 1579 + all AppGini Helper tools
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
[code]...[/code]
blocks for better readabilityAppGini 24.10 Revision 1579 + all AppGini Helper tools
- D Oliveira
- AppGini Super Hero
- Posts: 347
- Joined: 2018-03-04 09:30
- Location: David
Re: How to send WhatsApp messages to phones using PHP
jsetzer wrote: ↑2020-05-26 04:58D Oliveira wrote: ↑2020-05-26 04:46Hey Jan, I have something that could help you, mobile version will use native whatsapp and desktop version will use whatsapp web, hope it helps =)
Code: Select all
<div> <button onclick="share();" style="background-color:rgba(0,0,0,0.4);border-top-left-radius: 5px;border-bottom-left-radius: 5px;border-top-right-radius: 5px;border-bottom-right-radius: 5px;color:white;font-size:20px;font-family:Gotham2;border:0.1px solid black;padding: 5px 10px 7px;"> Share via Whatsapp </button> </div> <div> <img src="spacer.png?c=91" style="width:100%;height:50px;"> </div> <?php function isMobile() { return preg_match("/(android|avantgo|blackberry|bolt|boost|cricket|docomo|fone|hiptop|mini|mobi|palm|phone|pie|tablet|up\.browser|up\.link|webos|wos)/i", $_SERVER["HTTP_USER_AGENT"]); } if(isMobile()){ ?> <script> function share(){ LinkTextToShare = 'https://api.whatsapp.com/send?text=' + encodeURIComponent(window.location.href) ; popup_window = window.open(LinkTextToShare,"_blank"); //setInterval(function(){ popup_window.close (); }, 1000); popup_window.close (); } </script> <?php }else{ ?> <script> function share(){ LinkTextToShare = 'https://web.whatsapp.com/send?l=en&text=' + encodeURIComponent(window.location.href) ; popup_window = window.open(LinkTextToShare,"_blank"); } </script> <?php } ?> <img src="spacer.png?c=91" style="width:100%;height:30px;">
Hi,
thank you. Unfortunately this is clientside Javascript which requires a WhatsApp installation or an open WhatsAppWeb-session + additional user interaction.
I am looking for a server side PHP solution which I can use for mass sending WhatsApp messages to known phone numbers without user interaction per message.
Thank you both for taking the time!
Regards,
Jan
sorry for the confusion, maybe those links can help:
https://www.phphive.info/285/how-to-sen ... using-php/
https://www.twilio.com/docs/whatsapp/tu ... atsapp-php
http://www.vetbossel.in/send-and-receiv ... using-php/
Cheers!
Re: How to send WhatsApp messages to phones using PHP
I know this is an old thread, but I just posted a related recipe to the AppGini customization cookbook on GitHub: Share a record as a WhatsApp message
This is a client-side solution that opens the WhatsApp-web page, with a preselected contact and a pre-written message, ready for the user to click send. For sending automated server-side WhatsApp messages, I guess the only official way is to use the WhatsApp API -- I believe it's a commercial API rather than free.
This is a client-side solution that opens the WhatsApp-web page, with a preselected contact and a pre-written message, ready for the user to click send. For sending automated server-side WhatsApp messages, I guess the only official way is to use the WhatsApp API -- I believe it's a commercial API rather than free.
AppGini plugins to add more power to your apps:
- DataTalk is an innovative AppGini plugin based on ChatGPT that allows you to interact with your AppGini database using natural language questions, without writing any SQL. Check the demo video
- Mass Update plugin: Update multiple records at once and improve your workflow efficiency.
- Check our other plugins and get a generous discount of up to 30% when buying 2 or more plugins.
Re: How to send WhatsApp messages to phones using PHP
Great, this works perfectly for clientside 1:1 communication if the sender has connected her/his smartphone to WhatsApp Web. Thanks for sharing!
Serverside (API) usage: I did not find any free alternative, yet.
Serverside (API) usage: I did not find any free alternative, yet.
Kind regards,
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
AppGini 24.10 Revision 1579 + all AppGini Helper tools
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
[code]...[/code]
blocks for better readabilityAppGini 24.10 Revision 1579 + all AppGini Helper tools
Re: How to send WhatsApp messages to phones using PHP
Tips for text-formatting
Question:
Does anyone know the meaning of app_absent=0 parameter? Is there a parameter documentation somewhere?
- *bold*
- _italic_
- ~strike~
- ```monospace```
- you can use `\n` as newline-character
Question:
Does anyone know the meaning of app_absent=0 parameter? Is there a parameter documentation somewhere?
Kind regards,
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
AppGini 24.10 Revision 1579 + all AppGini Helper tools
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
[code]...[/code]
blocks for better readabilityAppGini 24.10 Revision 1579 + all AppGini Helper tools
Re: How to send WhatsApp messages to phones using PHP
Hi Jan,
just from curiosity: Why not simply send an email? That mail can be as short as a regular whatsapp message.
(Well, it's always good if we can - I agree)
Just a note from someone who might just be the only one here not using whatsapp
Olaf
just from curiosity: Why not simply send an email? That mail can be as short as a regular whatsapp message.
(Well, it's always good if we can - I agree)
Just a note from someone who might just be the only one here not using whatsapp
Olaf
Some postings I was involved, you might find useful:
SingleEdit - Prevent concurrent edits on records; Field Permissions; Column-Value-Based-Permissions; Custom (error) message; Audit Log; Backup your database; Two Factor Authentication; Block brute force (failed) logins; Add 2nd SAVE CHANGES button; Place a search on details view
SingleEdit - Prevent concurrent edits on records; Field Permissions; Column-Value-Based-Permissions; Custom (error) message; Audit Log; Backup your database; Two Factor Authentication; Block brute force (failed) logins; Add 2nd SAVE CHANGES button; Place a search on details view
Re: How to send WhatsApp messages to phones using PHP
Hi,
forgot, maybe, depending on usergroup you could use an instant messenger, based on email: https://delta.chat/
Olaf
forgot, maybe, depending on usergroup you could use an instant messenger, based on email: https://delta.chat/
Olaf
Some postings I was involved, you might find useful:
SingleEdit - Prevent concurrent edits on records; Field Permissions; Column-Value-Based-Permissions; Custom (error) message; Audit Log; Backup your database; Two Factor Authentication; Block brute force (failed) logins; Add 2nd SAVE CHANGES button; Place a search on details view
SingleEdit - Prevent concurrent edits on records; Field Permissions; Column-Value-Based-Permissions; Custom (error) message; Audit Log; Backup your database; Two Factor Authentication; Block brute force (failed) logins; Add 2nd SAVE CHANGES button; Place a search on details view
Re: How to send WhatsApp messages to phones using PHP
@Olaf: In my case (see beginning of this thread) a customer of mine had dozens of workers on construction sites. They are used to receive all organizational information in there specific WhatsApp team-group. So for that use case it is not an option to completely change their usual information-flow. Thanks for the link. I will definately have a look at this.
Kind regards,
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
AppGini 24.10 Revision 1579 + all AppGini Helper tools
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
[code]...[/code]
blocks for better readabilityAppGini 24.10 Revision 1579 + all AppGini Helper tools
Re: How to send WhatsApp messages to phones using PHP
By the way:
Thanks to Ahmed's WhatsApp recipe (see above) I have just included a WhatsApp link in one of my login pages (just as an idea).
It allows users to send the URL of that specific website via WhatsApp to others or to themselves. It is a little bit faster and more conveniant than copy&paste.
Other elements inside the "Connect" box:
Thanks to Ahmed's WhatsApp recipe (see above) I have just included a WhatsApp link in one of my login pages (just as an idea).
It allows users to send the URL of that specific website via WhatsApp to others or to themselves. It is a little bit faster and more conveniant than copy&paste.
Other elements inside the "Connect" box:
- The "paperplane" button opens up your mail client and creates a new mail, already containing the URL as link. So you can send the URL by email with very few clicks.
- The QR code can be scanned with your smartphone (if it has QR Code scanner integrated or as an installed app) and directly opens the same page.
Kind regards,
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
AppGini 24.10 Revision 1579 + all AppGini Helper tools
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
[code]...[/code]
blocks for better readabilityAppGini 24.10 Revision 1579 + all AppGini Helper tools
Re: How to send WhatsApp messages to phones using PHP
@Olaf:
Once again thank you for sharing the DeltaChat tip for automated sending messages to Smartphones which have installed DeltaChat client.
Unfortunately, I did not get it running, yet, and I would appreciate your help and experiences.
Status quo
Problem
I did not manage to send an e-mail (for example using PHP or by a standard e-mail client) to a DeltaChat client (Desktop or smartphone).
Analysis
When watching the email inbox while sending a message using one of the DeltaChat clients I have seen that DeltaChat uses attachments for data-transfer. They are using PGP (pretty good privacy).
As you can see from the following screenshot, such a message does NOT contain any contents but two attachments:
The .asc file contains PGP-encrypted data.
The .pgp file just contains three lines (two of them are empty):
Right now I have no idea how to encrypt my plain-text or HTML-messages using a PGP key of a recipient if I only have the recipient's email address.
So my question is:
How can I send a message to a DeltaChat client without using a DeltaChat client itself?
Thanks again for your recommendation and support!
Once again thank you for sharing the DeltaChat tip for automated sending messages to Smartphones which have installed DeltaChat client.
Unfortunately, I did not get it running, yet, and I would appreciate your help and experiences.
Status quo
- As you have suggested, I have installed DeltaChat on my PC and on my Smartphone
- I have setup a blank new email account just for testing purposes
- I have connected both clients (Desktop + Smartphone) with that email account
That's fine: I can use those DeltaChat clients on different devices for sending and receiving messages.
Problem
I did not manage to send an e-mail (for example using PHP or by a standard e-mail client) to a DeltaChat client (Desktop or smartphone).
Analysis
When watching the email inbox while sending a message using one of the DeltaChat clients I have seen that DeltaChat uses attachments for data-transfer. They are using PGP (pretty good privacy).
As you can see from the following screenshot, such a message does NOT contain any contents but two attachments:
The .asc file contains PGP-encrypted data.
The .pgp file just contains three lines (two of them are empty):
Right now I have no idea how to encrypt my plain-text or HTML-messages using a PGP key of a recipient if I only have the recipient's email address.
So my question is:
How can I send a message to a DeltaChat client without using a DeltaChat client itself?
Thanks again for your recommendation and support!
Kind regards,
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
AppGini 24.10 Revision 1579 + all AppGini Helper tools
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
[code]...[/code]
blocks for better readabilityAppGini 24.10 Revision 1579 + all AppGini Helper tools
Re: How to send WhatsApp messages to phones using PHP
Hi Jan,
oh well, I did not try this before myself, maybe I am not of a big help here but. I thought as DeltaChat is essentially using email it should be able to receive standard mail....
Looking at the headers I find
Maybe you need to send the headers along, so that DeltaChat recognizes, that the mail is intended for it. For the second line see specifications here: https://autocrypt.org/examples.html .
Hope this helps .. a little.
Olaf
oh well, I did not try this before myself, maybe I am not of a big help here but. I thought as DeltaChat is essentially using email it should be able to receive standard mail....
Looking at the headers I find
Code: Select all
Chat-Version: 1.0
Autocrypt: [email protected]; prefer-encrypt=mutual;
Hope this helps .. a little.
Olaf
Some postings I was involved, you might find useful:
SingleEdit - Prevent concurrent edits on records; Field Permissions; Column-Value-Based-Permissions; Custom (error) message; Audit Log; Backup your database; Two Factor Authentication; Block brute force (failed) logins; Add 2nd SAVE CHANGES button; Place a search on details view
SingleEdit - Prevent concurrent edits on records; Field Permissions; Column-Value-Based-Permissions; Custom (error) message; Audit Log; Backup your database; Two Factor Authentication; Block brute force (failed) logins; Add 2nd SAVE CHANGES button; Place a search on details view
Re: How to send WhatsApp messages to phones using PHP
Hi Jan,
maybe write yourself a message from DeltaChat (to your regular email account) and look at this message. Can you reply to that and receive it on DeltaChat? If yes, you should probably be able to take the message apart and send directly (without anyone initiating the "chat" first).
Just a thought.
Olaf
maybe write yourself a message from DeltaChat (to your regular email account) and look at this message. Can you reply to that and receive it on DeltaChat? If yes, you should probably be able to take the message apart and send directly (without anyone initiating the "chat" first).
Just a thought.
Olaf
Some postings I was involved, you might find useful:
SingleEdit - Prevent concurrent edits on records; Field Permissions; Column-Value-Based-Permissions; Custom (error) message; Audit Log; Backup your database; Two Factor Authentication; Block brute force (failed) logins; Add 2nd SAVE CHANGES button; Place a search on details view
SingleEdit - Prevent concurrent edits on records; Field Permissions; Column-Value-Based-Permissions; Custom (error) message; Audit Log; Backup your database; Two Factor Authentication; Block brute force (failed) logins; Add 2nd SAVE CHANGES button; Place a search on details view
Re: How to send WhatsApp messages to phones using PHP
Just wanted to chime in with this related tip.
Would it be possible to convince the customer to use Telegram instead of (or in addition to WhatsApp)? Telegram has a super, free, API that makes it very easy to send messages from PHP. At work we use it to monitor server uptime, mail queues etc and I get a Telegram message whenever anything needs attention. We also have connected it to our CRM system to "ring the bell" whenever new sales contracts are closed.
Eagle.
Would it be possible to convince the customer to use Telegram instead of (or in addition to WhatsApp)? Telegram has a super, free, API that makes it very easy to send messages from PHP. At work we use it to monitor server uptime, mail queues etc and I get a Telegram message whenever anything needs attention. We also have connected it to our CRM system to "ring the bell" whenever new sales contracts are closed.
Eagle.
Re: How to send WhatsApp messages to phones using PHP
Thank you for your idea with Telegram API. I will keep it in mind for future projects. In this specific project, we will not be able to completely convert their staff to the use of telegram. WhatsApp has been used there for years in various process-steps, and as a manufacturer of a partial solution I cannot change the process information flow.
Anyway, thanks for the idea. I think it is very valuable that you have already gained experience with this.
Anyway, thanks for the idea. I think it is very valuable that you have already gained experience with this.
Kind regards,
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
AppGini 24.10 Revision 1579 + all AppGini Helper tools
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
[code]...[/code]
blocks for better readabilityAppGini 24.10 Revision 1579 + all AppGini Helper tools