File: /home/imensosw/www/imenso.co/dev/transunion/Eligibility.php
<?php
ob_start();
$obj = new stdClass;
$obj->source = new stdClass;
$obj->source->type = "Payer";
$obj->source->payerId = $_POST['payerId'];
$obj->source->organizationName = $_POST['organizationName'];
$obj->transactionId = $_POST['transactionId'];
$obj->serviceDate = $_POST['serviceDate'];
$obj->receiver = new stdClass;
$obj->receiver->npi = $_POST['npi'];
$obj->receiver->payerProviderId = $_POST['payerProviderId'];
$obj->receiver->organizationName = $_POST['receiverorganizationName'];
$obj->subscriber = new stdClass;
$obj->subscriber->lastName = $_POST['lastName'];
$obj->subscriber->firstName = $_POST['firstName'];
$obj->subscriber->memberId = $_POST['memberId'];
$obj->subscriber->dateOfBirth = $_POST['dateOfBirth'];
$obj->benefits = array(array("serviceTypeCodes" =>[""]));
$username = "2013227";
$password = "thI!W1x4";
$url = "https://services.hsp.transunion.com/rest/payers/".$_POST['payerId']."/eligibility/query";
$headers = array(
'Content-Type: application/json',
'Authorization: Basic '. base64_encode($username.":".$password),
);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($obj));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
$return = curl_exec($ch);
curl_close($ch);
echo json_encode($return);
?>