Current File : /home/inlingua/public_html/crm.vprotectindia.com/whatts-app-api/index.php
<?php
$token = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJwaG9uZU51bWJlciI6Iis5MTg0NDcxMjQ5NjYiLCJwaG9uZU51bWJlcklkIjoiMTM3NjUzNDQ5NDI4NTg4IiwiaWF0IjoxNjk1NzI5ODkxfQ.zouNW93K9Je56uNrDoyHqLWwrApcZbyUtsl88rpd7wo';
$apiBase = 'https://wb.omni.tatatelebusiness.com/whatsapp-cloud/messages';

$account="6032504131";
$amount="2000";
$name="valuable Customer";
function sendTextMessage($phone, $templateName, $langCode) {
    global $token, $apiBase,$account,$amount,$name;
    $body =[
  "to"=> $phone,
  "type"=> "template",
  "source"=> "external",
  "template"=> [
    "name"=> "bill_generate_notifications",
    "language"=> [
      "code"=> "en"
    ],
    "components"=> [
      [
        "type"=> "header",
        "parameters"=> [
          [
            "type"=> "image",
            "image"=> [
              "link"=> "https://crm.vprotectindia.com/public/user/img/brand/white.png"
            ]
          ]
        ]
      ],
      
      [
        "type"=> "body",
        "parameters"=> [
          [
            "type"=> "text",
            "text"=> "7576576"
          ],
          [
            "type"=> "text",
            "text"=> "2000"
          ]
,
          [
            "type"=> "text",
            "text"=> "25 August 2025 "
          ]
        ]
      ],[
        "type"=> "button",
        "sub_type"=> "URL",
        "index"=> 1,
        "parameters"=> [
          [
            "type"=> "text",
            "text"=> "6032504131"
          ]
        ]
      ]
    ]
  ],
  "metaData"=> [
    "custom_callback_data"=> "<optional_value>"
  ]
];
//echo '<pre>'; echo json_encode($body); exit;
    $ch = curl_init("$apiBase");
    curl_setopt_array($ch, [
        CURLOPT_POST => true,
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_HTTPHEADER => [
            "Authorization:$token",
            "accept: application/json",
            "content-type: application/json; charset=utf-8 "
        ],
        CURLOPT_POSTFIELDS => json_encode($body)
    ]);
    $resp = curl_exec($ch);
    curl_close($ch);
    return json_decode($resp, true);
}

// Example usage
if(isset($_GET['mob']) && $_GET['mob'] !=''){
  
 $mob='91'.$_GET['mob']; 
} else {
  $mob='919643656504';
}  
  


$response = sendTextMessage(
    $mob, 
    'bangalore_beatparol', 
    'en');

print_r($response);

?>