<?php
class sms{
	static function sms_send($apikey,$mobile,$content) {
		header("Content-Type:text/html;charset=utf-8");
		$ch = curl_init();

		/* 设置验证方式 */

		curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept:text/plain;charset=utf-8', 'Content-Type:application/x-www-form-urlencoded','charset=utf-8'));

		/* 设置返回结果为流 */
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

		/* 设置超时时间*/
		curl_setopt($ch, CURLOPT_TIMEOUT, 10);

		/* 设置通信方式 */
		curl_setopt($ch, CURLOPT_POST, 1);
		curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
		$data=array('text'=>$content,'apikey'=>$apikey,'mobile'=>$mobile);
		$json_data = self::send($ch,$data);
		$array = json_decode($json_data,true);
		return $array;
	}
	public function send($ch,$data){
	    curl_setopt ($ch, CURLOPT_URL, 'https://sms.yunpian.com/v1/sms/send.json');
	    curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
	    return curl_exec($ch);
	}
}
?>