I want to send a message over WhatsApp from a php file. I've already discovered the library which let do it and it works in this way:
<?php
include_once './src/whatsprot.class.php';
function send($target,$message){
$username = "phone";
$password = "password";
$w = new WhatsProt($username,"Nickname", true); //Name your application by replacing “WhatsApp Messaging”
$w->connect();
$w->loginWithPassword($password);
$w->SendPresenceSubscription($target); //Let us first send presence to user
$w->sendMessage($target,$message ); // Send Message
}
send("phone","Text of the message");
?>
If I try to execute this or launch it via a php web server it works. If I try to call the method send($target,$message); from another php file, like this, it doesn't work:
<?php
include "whatsapp.php";
send($target, $message);
?>
What's the problem? How can I fix it?