I'm trying to use the WhatsApi Official library to send a message via WhatsApp from a php file. I've moved in my Apache web server the library, in a folder call test, like this:
The file whatsapp.php is this one:
<?php
require_once './src/whatsprot.class.php';
$username = "1XXXXXXXXX";
$password = "password";
$w = new WhatsProt($username, "0", "My Nickname", true); //Name your application by replacing “WhatsApp Messaging”
$w->connect();
$w->loginWithPassword($password);
$target = '1xxxxxxxxx'; //Target Phone,reciever phone
$message = 'This is my messagge';
$w->SendPresenceSubscription($target); //Let us first send presence to user
$w->sendMessage($target,$message ); // Send Message
echo "Message Sent Successfully";
?>
I'm facing some problem with the library new WhatsProt(), which blocks all the code (may be sockets ?).
So my question is, how can I fix this problem ? If no, are there any other solution to send message from a pho script ?
Texting with WhatsApp Tap the text bar at the bottom of the screen. Your keyboard will appear. Type the message you want to send, then tap the send button. Your message will be sent.
How to get a free account. You can register your account via email, or you can sign in directly to app.chat-api.com using your Google Account or GitHub Account. You need to create a developer instance on the "Add new instance" page. A developer instance can only be a single instance on an account.
You can use below script to send message from whatsapp in PHP
.
https://github.com/venomous0x/WhatsAPI/tree/master/examples
Configure the source code in Apache
and run examples/whatsapp.php
file.
You have change below configurations.
//simple password to view this script
$config['webpassword'] = 'MakeUpPassword';
and
$config['YOURNAME'] = array(
'id' => 'e807f1fcf82d132f9bb018ca6738a19f',
'fromNumber' => '441234567890',
'nick' => "YOURNICKNAME",
'waPassword' => "EsdfsawS+/ffdskjsdhwebdgxbs=",
'email' => '[email protected]',
'emailPassword' => 'gmailpassword'
);
It's working for me..
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With