<?php
	set_time_limit(0);
		
	function sendSms($ID,$Pwd,$remoteApp,$Mobno,$Text)
	{
                                            
		$request =""; //initialise the request variable
		$param[method]= "sendMessage";
		$param[send_to] = "91".$Mobno;
		//$param[send_to] = "919427589777";
		
		$param[msg] = $Text;
		$param[userid] = $ID;
		$param[password] = $Pwd;
		$param[v] = "1.1";
		$param[msg_type] = "UNICODE_TEXT"; //Can be "FLASH"/"UNICODE_TEXT"/"BINARY"
		$param[auth_scheme] = "PLAIN";
		//Have to URL encode the values
		foreach($param as $key=>$val) {
		$request.= $key."=".urlencode($val);
		//we have to urlencode the values
		$request.= "&";
		//append the ampersand (&) sign after each
		
		}
		$request = substr($request, 0, strlen($request)-1);
		//remove final (&) sign from the request
		$url = $remoteApp.$request;
		
		$ch = curl_init($url);
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
		
		$curl_scraped_page = curl_exec($ch);
		
		curl_close($ch);
		return($curl_scraped_page);
	}
			
	function getBalance($ID,$Pwd,$remoteApp)
	{
		$request =""; //initialise the request variable
			
		$url = "http://enterprise.smsgupshup.com/apps/apis/accInfo?userid=2000163671sdfsd&password=43vHSHCWvsdfsd&method=balanceCheck";
		
		$ch = curl_init($url);
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
		
		$curl_scraped_page = curl_exec($ch);
		
		if(curl_errno($ch)){
    			return 'Curl error: ' . curl_error($ch);
		}else{
			$temp=$curl_scraped_page;		
		
			$temp_arry = explode(":",$temp);
			
			if(count($temp_arry)>0){
				return $temp_arry[1];
			}
			else{
				return 0;
			}
			
		}
		curl_close($ch);		
	}
?>


