Advertisement
Guest User

Untitled

a guest
Apr 12th, 2016
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.97 KB | None | 0 0
  1. <?php
  2. ini_set('display_errors',1);
  3. error_reporting(E_ALL);
  4. set_time_limit(10);
  5. var_dump(extension_loaded('curve25519'));
  6. var_dump( extension_loaded('protobuf'));
  7. //require_once __DIR__.'../vendor/whatsapp/autoload.php';
  8. date_default_timezone_set('Europe/Madrid');
  9. //require_once __DIR__.'../vendor/whatsapp/chat-api/src/whatsprot.class.php';
  10. require_once 'vendor/whatsapp/chat-api/src/whatsprot.class.php';
  11. require_once 'vendor/whatsapp/chat-api/src/events/MyEvents.php';
  12. //require_once __DIR__.'/../src//events/MyEvents.php';
  13.  
  14. $username = '92xxxxxxxxx'; // Telephone number including the country code without '+' or '00'.
  15. $password = 't7+YzhqpUd8P7LgeU9NdttaIpc4='; // Use registerTool.php or exampleRegister.php to obtain your password
  16. $nickname = 'ADD Agent'; // This is the username (or nickname) displayed by WhatsApp clients.
  17. $target = "92xxxxxxxxx"; // Destination telephone number including the country code without '+' or '00'.
  18. $target = "92xxxxxxxxx"; // Destination telephone number including the country code without '+' or '00'.
  19. $debug = true; // Set this to true, to see debug mode.
  20.  
  21. echo "[] Logging in as '$nickname' ($username)n";
  22. //Create the whatsapp object and setup a connection.
  23. $w = new WhatsProt($username, $nickname, $debug,true,__DIR__.'/wadata/');
  24. $events = new MyEvents($w);
  25. $events->setEventsToListenFor($events->activeEvents);
  26.  
  27. $w->connect();
  28. // Now loginWithPassword function sends Nickname and (Available) Presence
  29. $w->loginWithPassword($password);
  30. $w->sendMessage($target, 'Salam kia haal hain?!');
  31. echo "<b>Message Sent to $target</b>";
  32.  
  33. echo "<br>Getting message<br>";
  34. $w->pollMessage();
  35. $msgs = $w->GetMessages();
  36. foreach ($msgs as $m) {
  37. var_dump($m);
  38. }
  39.  
  40. public function onGetMessage( $mynumber, $from, $id, $type, $time, $name, $body )
  41. {
  42. echo "<br>Message Got from $name:n$bodynn<br>"; // NOT being fired.
  43. exit;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement