<?php

			$accountid	=	"xxxxxxx";//云呼账号 
			$secret		=	"xxxxxxx";//云呼密码
			$time		=	date("YmdHis");
//echo $time;exit;
			$authorization	=	base64_encode($accountid.":".$time);
			$sig			=	strtoupper(md5($accountid.$secret.$time));
//echo $authorization;
//echo "<br>";


			$url	=	"".$accountid."?sig=".$sig;
			$data	=	array("midNum"=>$midNum,"called"=>$called,"caller"=>$caller);

		
//print_r(  http_build_query($data) );exit;
//echo $url;
//exit;
	//echo strlen( http_build_query($data) );exit;
			//$header[] = 'Connection: Keep-Alive';
			$header[] = "Accept: application/json";
			$header[] = "Content-type: application/json;charset='utf-8'";
			$header[] = "Content-Length: ".strlen( json_encode($data) );
			$header[] = "Authorization: ".$authorization;



		//print_r($header);
	
			$ch = curl_init ();
			curl_setopt($ch, CURLOPT_URL, ($url) );//地址
			curl_setopt($ch, CURLOPT_POST, 1);   //请求方式为post
			curl_setopt($ch, CURLOPT_POSTFIELDS,json_encode($data)); //post传输的数据。
			curl_setopt($ch, CURLINFO_HEADER_OUT, true);
			curl_setopt($ch, CURLOPT_HTTPHEADER,$header);
			curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); 
			curl_setopt($ch, CURLOPT_TIMEOUT, 60);

			//print_r($message);exit;

			$return = curl_exec ( $ch );
			
			if($return === FALSE ){
				echo "CURL Error:".curl_error($ch);exit;
			 }

			curl_close ( $ch );
	
	
			
		
		echo ($return);
		exit;



?>