whatsapp.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. //// Facebook verification
  3. //if ($_SERVER['REQUEST_METHOD'] === 'GET') {
  4. // $verify_token = 'EAAJB2BlGxRMBO62lsPzKpIZA0ZAojmgqubtBdTX6WJpFoDeISffzlcObVG1y0o9J2sGcYPOPfaG0mhSGKHSDFY67njunqRQIL3YMsNE8xC5NDQ2TgKdjfib6tjhfVT0Tg8XMKt7yvN9NP3GQek3i4oB3AXl5dX5bBuFfhZB0YbHgXJbNohMXHZCHRBCSw1PmsECK3j3BjxZCoRiV7PGwuoKFCFc3M5UiRjiUqaZBsT';
  5. // if ($_GET['hub_verify_token'] === $verify_token) {
  6. // echo $_GET['hub_challenge'];
  7. // exit;
  8. // } else {
  9. // http_response_code(403);
  10. // exit;
  11. // }
  12. //}
  13. //
  14. //
  15. //// Receive Message from WhatsApp
  16. //if ($_SERVER['REQUEST_METHOD'] === 'POST') {
  17. // $input = json_decode(file_get_contents('php://input'), true);
  18. // $message = $input['entry'][0]['changes'][0]['value']['messages'][0]['text']['body'];
  19. // $from = $input['entry'][0]['changes'][0]['value']['messages'][0]['from'];
  20. //
  21. // $token = 'EAAJB2BlGxRMBOZBj1DZArQo02p6hqxEluzCzbSvNvlNs7fBtb2tv57KZAflNUte6j9ip37ZCXmUVXZBZCtp44Sb93Gb83dh2ZAEBZA3ZCbzAlwl47CPtjkWi0pEIE5f1Fi1hkZCWcyXs6ZBQVzZBicCcOZBNStGMHOCwQZCmLqMT5U9Juv7L0eQbvTUB6clwtFnvZBmJA2ZASgPymjBC04odbwCiP5TSzNZBG3iZAs6ULecUkZD';
  22. // $phone_id = '706930449163857';
  23. //
  24. // $url = "https://graph.facebook.com/v19.0/$phone_id/messages";
  25. //
  26. // $msg_encoded = urlencode($message);
  27. // $bot_url = "https://agent.cybob.com/awigo/?controller=message&message=$msg_encoded";
  28. //
  29. // $ch2 = curl_init($bot_url);
  30. // curl_setopt($ch2, CURLOPT_RETURNTRANSFER, true);
  31. // curl_setopt($ch2, CURLOPT_ENCODING, '');
  32. // curl_setopt($ch2, CURLOPT_FOLLOWLOCATION, true);
  33. // $bot_response = curl_exec($ch2);
  34. // $curl_error = curl_error($ch2);
  35. // curl_close($ch2);
  36. //
  37. // $bot_data = json_decode($bot_response, true);
  38. //
  39. // if (isset($bot_data['reply'])) {
  40. // $reply = $bot_data['reply'];
  41. // $reply = strip_tags(html_entity_decode($reply));
  42. // } else {
  43. // $reply = "Botfehler:\nAntwort: $bot_response\nFehler: $curl_error";
  44. // }
  45. //
  46. // $payload = [
  47. // "messaging_product" => "whatsapp",
  48. // "to" => $from,
  49. // "type" => "text",
  50. // "text" => ["body" => $reply]
  51. // ];
  52. //
  53. // $ch = curl_init($url);
  54. // curl_setopt($ch, CURLOPT_HTTPHEADER, [
  55. // "Authorization: Bearer $token",
  56. // "Content-Type: application/json"
  57. // ]);
  58. // curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload));
  59. // curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  60. // curl_exec($ch);
  61. // curl_close($ch);
  62. //
  63. // echo json_encode(["status" => "ok"]);
  64. // exit;
  65. //}
  66. //?>