<?php 

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

$apikey = $apidata['APIkey']; 
$url = $apidata['baseurl'];

$deno=$amount;
$quantity=$pinNo;
$requestId = 7777777778;
 
$host = "https://vtuafrica.com.ng/portal/api/airtime-pin/index.php?apikey=$apikey&network=$network&amount=$deno&quantity=$quantity&variation=$variation&ref=$requestId&maxamount=$debit";



//Initialize cURL.


$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $host);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
$vdata = curl_exec($ch);
$result1 = json_decode($vdata, true);
$result = json_decode($vdata);
//Close the cURL handle.
curl_close($ch);

if($result->code =='101'){
$mypin	= $result->description->pins;
$pnt = $result->description->ProductName;
$net = $network; 
$spac = explode(",", $mypin);
							
foreach ($spac as $pins) {
  
$sto = mysqli_query($conn,"INSERT INTO mypin (service,ref,net,cat,pins,amount,email,del,date)VALUES('$pnt','$requestId','$net','$deno','$pins','$debit','$user','$del','$date');");
 }
	
$stat = "Completed";
}else{
$stat = "Failed";
}


?>