Advertisement
Yesver08

whatsapp.php

Aug 4th, 2023
1,095
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.83 KB | Source Code | 0 0
  1. <?php
  2.  
  3. function sendWhatsappMessage(string $target, string $message): bool
  4. {
  5.     $token = 'TOKEN';
  6.     $curl = curl_init();
  7.     curl_setopt_array($curl, array(
  8.         CURLOPT_URL => 'https://api.fonnte.com/send',
  9.         CURLOPT_RETURNTRANSFER => true,
  10.         CURLOPT_ENCODING => '',
  11.         CURLOPT_MAXREDIRS => 10,
  12.         CURLOPT_TIMEOUT => 0,
  13.         CURLOPT_FOLLOWLOCATION => true,
  14.         CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  15.         CURLOPT_CUSTOMREQUEST => 'POST',
  16.         CURLOPT_POSTFIELDS => array(
  17.             'target' => $target,
  18.             'message' => $message,
  19.         ),
  20.         CURLOPT_HTTPHEADER => array(
  21.             'Authorization: ' . $token
  22.         ),
  23.     ));
  24.     $response = curl_exec($curl);
  25.     curl_close($curl);
  26.  
  27.     $data = json_decode($response, false);
  28.     return $data->status;
  29. }
  30.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement