Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- ini_set('display_errors',1);
- error_reporting(E_ALL);
- set_time_limit(10);
- var_dump(extension_loaded('curve25519'));
- var_dump( extension_loaded('protobuf'));
- //require_once __DIR__.'../vendor/whatsapp/autoload.php';
- date_default_timezone_set('Europe/Madrid');
- //require_once __DIR__.'../vendor/whatsapp/chat-api/src/whatsprot.class.php';
- require_once 'vendor/whatsapp/chat-api/src/whatsprot.class.php';
- require_once 'vendor/whatsapp/chat-api/src/events/MyEvents.php';
- //require_once __DIR__.'/../src//events/MyEvents.php';
- $username = '92xxxxxxxxx'; // Telephone number including the country code without '+' or '00'.
- $password = 't7+YzhqpUd8P7LgeU9NdttaIpc4='; // Use registerTool.php or exampleRegister.php to obtain your password
- $nickname = 'ADD Agent'; // This is the username (or nickname) displayed by WhatsApp clients.
- $target = "92xxxxxxxxx"; // Destination telephone number including the country code without '+' or '00'.
- $target = "92xxxxxxxxx"; // Destination telephone number including the country code without '+' or '00'.
- $debug = true; // Set this to true, to see debug mode.
- echo "[] Logging in as '$nickname' ($username)n";
- //Create the whatsapp object and setup a connection.
- $w = new WhatsProt($username, $nickname, $debug,true,__DIR__.'/wadata/');
- $events = new MyEvents($w);
- $events->setEventsToListenFor($events->activeEvents);
- $w->connect();
- // Now loginWithPassword function sends Nickname and (Available) Presence
- $w->loginWithPassword($password);
- $w->sendMessage($target, 'Salam kia haal hain?!');
- echo "<b>Message Sent to $target</b>";
- echo "<br>Getting message<br>";
- $w->pollMessage();
- $msgs = $w->GetMessages();
- foreach ($msgs as $m) {
- var_dump($m);
- }
- public function onGetMessage( $mynumber, $from, $id, $type, $time, $name, $body )
- {
- echo "<br>Message Got from $name:n$bodynn<br>"; // NOT being fired.
- exit;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement