<?php


$qryApi = mysqli_query($conn,"SELECT * FROM api_setting");

$apidata = mysqli_fetch_array($qryApi);


$apikey = $apidata['APIkey']; //email address()

$url = $apidata['baseurl'];




$host = "https://vtuafrica.com.ng/portal/api/electric/?apikey=$apikey&service=$network&meterNo=$iuc&metertype=$plan&amount=$xamount&ref=$requestId";




//Initialize cURL.

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, $host);

curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);


$dataR = curl_exec($ch);

$result = json_decode($dataR);


//Close the cURL handle.

curl_close($ch);

$APImessage = $result->description->message;


if($result->code =='101'){
	
$units = $result->description->Unit;
$token = $result->description->Token;

$qsel2 = "INSERT INTO mypin (net,pins,sn,amount,email,action,del)VALUES('$network','$token','$units','$debit','$user','$action','$del')";
$savz = $conn->query($qsel2);

$stat = "Completed";

}else{
$stat = "Failed";
}

?>