<?php
    include'connection.php';
    include'functions.php';
    
    $mobile=1349525889;
	$operator="Tata Sky";
	$apiKey="d1db51a3a6a8ef6078fd8bf623dd0008";
	
	$url="https://www.mplan.in/api/dthplans.php?";

	$ch = curl_init();

    if (!$ch)
    {
        die("Couldn't initialize a cURL handle");
    }
    curl_setopt($ch, CURLOPT_URL,$url); // 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);

    //apikey=[yourapikey]&operator=[operator](Given

	$apiUrl="apikey=$apiKey&operator=$operator";
	//$apiUrl="apikey=$apiKey&offer=roffer&tel=$mobile&operator=$operator";
	
    curl_setopt($ch, CURLOPT_POSTFIELDS,$apiUrl);
    echo '<pre>';
    echo $result = curl_exec ($ch); 

    die();
    $result = json_decode($result,true);
   
    $records=$result["records"];
     echo '<pre>';
    print_r($records);
    die();
    
    
    //$record = $result->record;
    //var_dump($record);
    //die();
        
       // echo "$x = $val<br>";
        foreach($records as $key => $recordsVal) {
            echo 'Record: '.$key;
            $rs=$recordsVal["rs"];
            $desc=$recordsVal["desc"];
            echo "RS: ".$rs." || DESC: ".$desc."<hr>";
        }
        
  
?>