<?php
    //require'connection.php';
    //require'functions.php';

    //$toMobile     = "8410930786";
    //$wmsg        = "Text Msg Coding";
    
    $apikey     = "3456d04dccf34b1bbc67e07dbe5899a4";
    $apiHTTPurl = "http://148.251.129.118/whatsapp/api/send?";
    $apiUrl     = "mobile=$toMobile&msg=$wmsg&apikey=$apikey";
    $req_url    = $apiHTTPurl.$apiUrl;

    $ch = curl_init();
	if (!$ch)
    {
        die("Couldn't initialize a cURL handle");
    }
    curl_setopt($ch, CURLOPT_URL,$apiHTTPurl); // Target URL
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
    curl_setopt($ch, CURLOPT_POST, 1);
	curl_setopt($ch, CURLOPT_POSTFIELDS,$apiUrl);
    $result = curl_exec ($ch);
    
    $insert = "INSERT INTO wmsg (Date,Time,UsrWno,Request,Result) VALUES ('$date','$time','$mobile','$req_url','$result')";
    mysqli_query($con,$insert);
    
    $response = (array)json_decode($result);
    
    $status     = $response['status'];
    $errormsg   = $response['errormsg'];
    $statuscode = $response['statuscode'];
    $requestid  = $response['requestid'];
    $msgcount   = $response['msgcount'];
    $msgcost    = $response['msgcost'];


?>