<?php
class rechargeMobileServices{
public function rechargeMobileOperation($request){
$url = "your services provider Host url";
$token = $request['Token'];
unset($request['Token']);
$xml_post_string = json_encode($request);
echo $xml_post_string;
$headers = array(
"Content-type: application/json",
"Accept: application/json",
"Cache-Control: no-cache",
"Pragma: no-cache",
"Content-length: " . strlen($xml_post_string),
"Authorization: TKN ". $token
);
// PHP cURL for https connection with auth
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml_post_string);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$response = curl_exec($ch);
return $response;
}
}
?>
|