<?php

//-----------------------------------------------------------------------------
// file: Sample.php
// auth: Cheng Liu <cliu@max.md>
// copy: (c) Copyright 2015 MaxMD Corp.
// desc: Get data from Restful API and download CSV file
//-----------------------------------------------------------------------------

//fill out the parameters below. You can find the parameter description on http://localhost:8080/Directory/
$hispOperatorUrl = "";
$directAddressUrl = "";
$stateListUrl = "";
$startdateUrl = "";
$enddateUrl = "";
$statusUrl = "";
$usernameUrl = "";
$md5HashedPasswordUrl = "";

$server_url = "https://directapi.max.md:8445/Directory/rest/getDirectory/$hispOperatorUrl/$directAddressUrl/$stateListUrl/$startdateUrl/$enddateUrl/$statusUrl/$usernameUrl/$md5HashedPasswordUrl";
echo $server_url;
$command = "curl -k $server_url";
$curl_response = shell_exec($command);

if ($curl_response === false) {
    $info = curl_getinfo($curl);
    curl_close($curl);
    die('error occured during curl exec. Additioanl info: ' . var_export($info));
}

$filename = "directoryphp.csv";
$file = fopen($filename,'w') or die("Unable to open file!");

fwrite($file, $curl_response);

fclose($file);
