PHP Classes

File: data/services/rechargeMobile/rechargeMobile.php

Recommend this page to a friend!
  Classes of Ruturaj Maniyar   PHP Mobile Recharge API   data/services/rechargeMobile/rechargeMobile.php   Download  
File: data/services/rechargeMobile/rechargeMobile.php
Role: Example script
Content type: text/plain
Description: Recharge Class file. This recharge library file that send the request to provider server.
Class: PHP Mobile Recharge API
Recharge mobile phone account balance
Author: By
Last change:
Date: 9 years ago
Size: 1,404 bytes
 

Contents

Class file image Download
<?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;
           
        }
    }
?>