<?php 

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

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


$host = "https://vtuafrica.com.ng/api/exam-pin/?apikey=$apikey&service=$network&product_code=$variation&quantity=$pinNo&profilecode=$iuc&MobileNumber=$phone&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);
//Close the cURL handle.
curl_close($ch);

$result1 = json_decode($vdata, true);
$result = json_decode($vdata);

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


if($result->code =='101'){
$mypin	= $result->description->pins;
$pnt = $result->description->ProductName;
$net = $network; 
$deno = $variation;
$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";
}


// 
?>