From 79ad053ba719b8d33d4e6d96a6dd3fbe415f23b1 Mon Sep 17 00:00:00 2001
From: colly <576734462@qq.com>
Date: Sat, 29 Jul 2017 09:27:47 +0800
Subject: [PATCH] 接口上传
---
Library/Alidayu/SDK/request/TopatsResultGetRequest.php | 48
Library/Alidayu/SDK/domain/FcPartnerSmsDetailDto.php | 50
Library/SMS/Lite.php | 297 +++
Library/Alidayu/SDK/request/TopIpoutGetRequest.php | 32
Public/yfs/listAllApis.php | 53
Config/app.php | 12
Library/Alidayu/SDK/RequestCheckUtil.php | 107 +
Library/Alidayu/Config/app.php | 16
Library/Alidayu/SDK/request/AlibabaAliqinFcTtsNumSinglecallRequest.php | 114 +
Library/Alidayu/SDK/TopLogger.php | 43
Library/SMS/SDK/REST.php | 1042 +++++++++++++
Library/Alidayu/SDK/ResultSet.php | 21
Library/Alidayu/Lite.php | 82 +
Library/Alidayu/SDK/domain/Subtask.php | 25
Library/Alidayu/SDK/request/AlibabaAliqinFcSmsNumSendRequest.php | 131 +
Library/Alidayu/SDK/request/TopSecretGetRequest.php | 64
Library/Alidayu/SDK/domain/KfcSearchResult.php | 29
Library/Alidayu/SDK/request/AppipGetRequest.php | 32
Library/Alidayu/SDK/request/AlibabaAliqinFcSmsNumQueryRequest.php | 115 +
Library/SMS/README.md | 81 +
Library/Alidayu/SDK/HttpdnsGetRequest.php | 23
Library/Alidayu/SDK/domain/Task.php | 52
Public/listAllApis.php | 53
Yfs/Model/SmsCode.php | 19
Library/Alidayu/SDK/request/AlibabaAliqinFcFlowChargeProvinceRequest.php | 98 +
Yfs/Domain/SmsCode.php | 65
Yfs/Domain/User.php | 59
Library/Alidayu/SDK/request/HttpdnsGetRequest.php | 32
Library/Alidayu/SDK/request/AlibabaAliqinFcFlowGradeRequest.php | 32
Library/Alidayu/SDK/ApplicationVar.php | 47
Library/Alidayu/SDK/domain/Result.php | 30
Library/Alidayu/SDK/TopClient.php | 375 ++++
Library/Alidayu/SDK/SpiUtils.php | 214 ++
Library/Alidayu/SDK/request/TimeGetRequest.php | 32
Library/Alidayu/SDK/request/AlibabaAliqinFcFlowChargeRequest.php | 98 +
Library/Alidayu/SDK/ClusterTopClient.php | 199 ++
Library/Alidayu/SDK/request/TopatsTaskDeleteRequest.php | 48
Yfs/Api/User.php | 165 +
Library/Alidayu/SDK/domain/BizResult.php | 30
Library/Alidayu/SDK/request/TopAuthTokenRefreshRequest.php | 48
Library/Alidayu/SDK/domain/Area.php | 35
Library/Alidayu/SDK/request/KfcKeywordSearchRequest.php | 85 +
PhalApi/PhalApi/Helper/api_desc_tpl.php | 26
Library/Alidayu/SDK/request/TopAuthTokenCreateRequest.php | 64
Public/yfs/checkApiParams.php | 34
Library/Alidayu/SDK/request/AlibabaAliqinFcVoiceNumDoublecallRequest.php | 131 +
Library/Alidayu/SDK/request/AreasGetRequest.php | 48
Library/SMS/Demo.php | 34
Library/Alidayu/SDK/request/AlibabaAliqinFcFlowQueryRequest.php | 47
Library/SMS/Config/app.php | 21
Yfs/Api/Send.php | 61
Library/Alidayu/SDK/request/AlibabaAliqinFcVoiceNumSinglecallRequest.php | 98 +
52 files changed, 4,699 insertions(+), 98 deletions(-)
diff --git a/Config/app.php b/Config/app.php
index dee7006..8e7cb02 100644
--- a/Config/app.php
+++ b/Config/app.php
@@ -24,4 +24,16 @@
'service_whitelist' => array(
'Default.Index',
),
+
+ 'alidayu' => array(
+ //������������
+ 'sign_name' => '������������',
+
+ //������������
+ 'templates' => array(
+ 'register' => 'SMS_71216225'
+ ),
+ 'app_key' => '23531128',
+ 'secretkey' => 'b079269785183c5a7520da9b8047bb42'
+ )
);
diff --git a/Library/Alidayu/Config/app.php b/Library/Alidayu/Config/app.php
new file mode 100644
index 0000000..02db954
--- /dev/null
+++ b/Library/Alidayu/Config/app.php
@@ -0,0 +1,16 @@
+<?php
+/**
+ * ������������
+ */
+return array(
+
+ 'alidayu' => array(
+ //������������
+ 'sign_name' => '������������',
+
+ //������������
+ 'templates' => array(
+ 'register' => '71245307'
+ )
+ )
+);
\ No newline at end of file
diff --git a/Library/Alidayu/Lite.php b/Library/Alidayu/Lite.php
new file mode 100644
index 0000000..1898620
--- /dev/null
+++ b/Library/Alidayu/Lite.php
@@ -0,0 +1,82 @@
+<?php
+
+/**
+ * ������������������
+ */
+class Alidayu_Lite{
+
+ static $_instance;
+
+ public $sign_name = '';
+
+ public $templates = array();
+
+ public $app_key = '';
+
+ public $secretkey = '';
+
+ public function __construct(){
+ DI()->loader->addDirs('./Library/Alidayu/SDK');
+ DI()->loader->addDirs('./Library/Alidayu/SDK/request');
+ DI()->loader->addDirs('./Library/Alidayu/SDK/domain');
+ $config = DI()->config->get('app.alidayu');
+ $this->sign_name = $config['sign_name'];
+ $this->templates = $config['templates'];
+ $this->app_key = $config['app_key'];
+ $this->secretkey = $config['secretkey'];
+ }
+
+ /**
+ * ������������
+ * @return [type] [description]
+ */
+ public static function getInstance(){
+ if(!(self::$_instance instanceof self)){
+ self::$_instance = new self();
+ }
+ return self::$_instance;
+ }
+
+ /**
+ * ���������������
+ * @param [type] $phone [description]
+ * @param [type] $data [description]
+ * @param [type] $use_scene [description]
+ * @return [type] [description]
+ */
+ public function send($phone, $send_json_data, $use_scene){
+ if(!empty($use_scene)){
+ if(isset($this->templates[$use_scene])){
+ return $this->_send($phone, $send_json_data, $this->templates[$use_scene]);
+ }
+ else{
+ return false;
+ }
+ }
+ else{
+ return false;
+ }
+ }
+
+ /**
+ * ������������������������������
+ * @param [type] $phone [description]
+ * @param [type] $send_json_data [description]
+ * @param [type] $template_id [description]
+ * @return [type] [description]
+ */
+ private function _send($phone, $send_json_data, $template_id){
+ $topClient = new TopClient();
+ $topClient->appkey = $this->app_key;
+ $topClient->secretKey = $this->secretkey;
+ $req = new AlibabaAliqinFcSmsNumSendRequest();
+ $req->setExtend($phone);
+ $req->setSmsType('normal');
+ $req->setSmsFreeSignName($this->sign_name);
+ $req->setSmsParam($send_json_data);
+ $req->setRecNum($phone);
+ $req->setSmsTemplateCode($template_id);
+ $resp = $topClient->execute($req);
+ return $resp;
+ }
+}
\ No newline at end of file
diff --git a/Library/Alidayu/SDK/ApplicationVar.php b/Library/Alidayu/SDK/ApplicationVar.php
new file mode 100644
index 0000000..528b2ba
--- /dev/null
+++ b/Library/Alidayu/SDK/ApplicationVar.php
@@ -0,0 +1,47 @@
+<?php
+
+class ApplicationVar
+{
+ var $save_file;
+ var $application = null;
+ var $app_data = '';
+ var $__writed = false;
+
+ function __construct()
+ {
+ $this->save_file = __DIR__.'/httpdns.conf' ;
+ $this->application = array();
+ }
+
+ public function setValue($var_name,$var_value)
+ {
+ if (!is_string($var_name) || empty($var_name))
+ return false;
+
+ $this->application[$var_name] = $var_value;
+ }
+
+ public function write(){
+ $this->app_data = @serialize($this->application);
+ $this->__writeToFile();
+ }
+
+ public function getValue()
+ {
+ if (!is_file($this->save_file))
+ $this->__writeToFile();
+ return @unserialize(@file_get_contents($this->save_file));
+ }
+
+ function __writeToFile()
+ {
+ $fp = @fopen($this->save_file,"w");
+ if(flock($fp , LOCK_EX | LOCK_NB)){
+ @fwrite($fp,$this->app_data);
+ flock($fp , LOCK_UN);
+ }
+ @fclose($fp);
+ }
+}
+
+?>
\ No newline at end of file
diff --git a/Library/Alidayu/SDK/ClusterTopClient.php b/Library/Alidayu/SDK/ClusterTopClient.php
new file mode 100644
index 0000000..8d1ca00
--- /dev/null
+++ b/Library/Alidayu/SDK/ClusterTopClient.php
@@ -0,0 +1,199 @@
+<?php
+class ClusterTopClient extends TopClient {
+
+ private static $dnsconfig;
+ private static $syncDate = 0;
+ private static $applicationVar ;
+ private static $cfgDuration = 10;
+
+ public function __construct($appkey = "",$secretKey = ""){
+ ClusterTopClient::$applicationVar = new ApplicationVar;
+ $this->appkey = $appkey;
+ $this->secretKey = $secretKey ;
+ $saveConfig = ClusterTopClient::$applicationVar->getValue();
+
+ if($saveConfig){
+ $tmpConfig = $saveConfig['dnsconfig'];
+ ClusterTopClient::$dnsconfig = $this->object_to_array($tmpConfig);
+ unset($tmpConfig);
+
+ ClusterTopClient::$syncDate = $saveConfig['syncDate'];
+ if(!ClusterTopClient::$syncDate)
+ ClusterTopClient::$syncDate = 0;
+ }
+ }
+
+ public function __destruct(){
+ if(ClusterTopClient::$dnsconfig && ClusterTopClient::$syncDate){
+ ClusterTopClient::$applicationVar->setValue("dnsconfig",ClusterTopClient::$dnsconfig);
+ ClusterTopClient::$applicationVar->setValue("syncDate",ClusterTopClient::$syncDate);
+ ClusterTopClient::$applicationVar->write();
+ }
+ }
+
+ public function execute($request = null, $session = null,$bestUrl = null){
+ $currentDate = date('U');
+ $syncDuration = $this->getDnsConfigSyncDuration();
+ $bestUrl = $this->getBestVipUrl($this->gatewayUrl,$request->getApiMethodName(),$session);
+ if($currentDate - ClusterTopClient::$syncDate > $syncDuration * 60){
+ $httpdns = new HttpdnsGetRequest;
+ ClusterTopClient::$dnsconfig = json_decode(parent::execute($httpdns,null,$bestUrl)->result,true);
+ $syncDate = date('U');
+ ClusterTopClient::$syncDate = $syncDate ;
+ }
+ return parent::execute($request,$session,$bestUrl);
+ }
+
+ private function getDnsConfigSyncDuration(){
+ if(ClusterTopClient::$cfgDuration){
+ return ClusterTopClient::$cfgDuration;
+ }
+ if(!ClusterTopClient::$dnsconfig){
+ return ClusterTopClient::$cfgDuration;
+ }
+ $config = json_encode(ClusterTopClient::$dnsconfig);
+ if(!$config){
+ return ClusterTopClient::$cfgDuration;
+ }
+ $config = ClusterTopClient::$dnsconfig['config'];
+ $duration = $config['interval'];
+ ClusterTopClient::$cfgDuration = $duration;
+
+ return ClusterTopClient::$cfgDuration;
+ }
+
+ private function getBestVipUrl($url,$apiname = null,$session = null){
+ $config = ClusterTopClient::$dnsconfig['config'];
+ $degrade = $config['degrade'];
+ if(strcmp($degrade,'true') == 0){
+ return $url;
+ }
+ $currentEnv = $this->getEnvByApiName($apiname,$session);
+ $vip = $this->getVipByEnv($url,$currentEnv);
+ if($vip)
+ return $vip;
+ return $url;
+ }
+
+ private function getVipByEnv($comUrl,$currentEnv){
+ $urlSchema = parse_url($comUrl);
+ if(!$urlSchema)
+ return null;
+ if(!ClusterTopClient::$dnsconfig['env'])
+ return null;
+
+ if(!array_key_exists($currentEnv,ClusterTopClient::$dnsconfig['env']))
+ return null;
+
+ $hostList = ClusterTopClient::$dnsconfig['env'][$currentEnv];
+ if(!$hostList)
+ return null ;
+
+ $vipList = null;
+ foreach ($hostList as $key => $value) {
+ if(strcmp($key,$urlSchema['host']) == 0 && strcmp($value['proto'],$urlSchema['scheme']) == 0){
+ $vipList = $value;
+ break;
+ }
+ }
+ $vip = $this->getRandomWeightElement($vipList['vip']);
+
+ if($vip){
+ return $urlSchema['scheme']."://".$vip.$urlSchema['path'];
+ }
+ return null;
+ }
+
+ private function getEnvByApiName($apiName,$session=""){
+ $apiCfgArray = ClusterTopClient::$dnsconfig['api'];
+ if($apiCfgArray){
+ if(array_key_exists($apiName,$apiCfgArray)){
+ $apiCfg = $apiCfgArray[$apiName];
+ if(array_key_exists('user',$apiCfg)){
+ $userFlag = $apiCfg['user'];
+ $flag = $this->getUserFlag($session);
+ if($userFlag && $flag ){
+ return $this->getEnvBySessionFlag($userFlag,$flag);
+ }else{
+ return $this->getRandomWeightElement($apiCfg['rule']);
+ }
+ }
+ }
+ }
+ return $this->getDeafultEnv();
+ }
+
+ private function getUserFlag($session){
+ if($session && strlen($session) > 5){
+ if($session[0] == '6' || $session[0] == '7'){
+ return $session[strlen($session) -1];
+ }else if($session[0] == '5' || $session[0] == '8'){
+ return $session[5];
+ }
+ }
+ return null;
+ }
+
+ private function getEnvBySessionFlag($targetConfig,$flag){
+ if($flag){
+ $userConf = ClusterTopClient::$dnsconfig['user'];
+ $cfgArry = $userConf[$targetConfig];
+ foreach ($cfgArry as $key => $value) {
+ if(in_array($flag,$value))
+ return $key;
+ }
+ }else{
+ return null;
+ }
+ }
+
+ private function getRandomWeightElement($elements){
+ $totalWeight = 0;
+ if($elements){
+ foreach ($elements as $ele) {
+ $weight = $this->getElementWeight($ele);
+ $r = $this->randomFloat() * ($weight + $totalWeight);
+ if($r >= $totalWeight){
+ $selected = $ele;
+ }
+ $totalWeight += $weight;
+ }
+ if($selected){
+ return $this->getElementValue($selected);
+ }
+ }
+ return null;
+
+ }
+
+ private function getElementWeight($ele){
+ $params = explode('|', $ele);
+ return floatval($params[1]);
+ }
+ private function getElementValue($ele){
+ $params = explode('|', $ele);
+ return $params[0];
+ }
+
+ private function getDeafultEnv(){
+ return ClusterTopClient::$dnsconfig['config']['def_env'];
+ }
+
+ private static function startsWith($haystack, $needle) {
+ return $needle === "" || strpos($haystack, $needle) === 0;
+ }
+
+ private function object_to_array($obj)
+ {
+ $_arr= is_object($obj) ? get_object_vars($obj) : $obj;
+ foreach($_arr as $key=> $val)
+ {
+ $val= (is_array($val) || is_object($val))? $this->object_to_array($val) : $val;
+ $arr[$key] = $val;
+ }
+ return$arr;
+ }
+
+ private function randomFloat($min = 0, $max = 1) { return $min + mt_rand() / mt_getrandmax() * ($max - $min); }
+}
+?>
\ No newline at end of file
diff --git a/Library/Alidayu/SDK/HttpdnsGetRequest.php b/Library/Alidayu/SDK/HttpdnsGetRequest.php
new file mode 100644
index 0000000..13adcf0
--- /dev/null
+++ b/Library/Alidayu/SDK/HttpdnsGetRequest.php
@@ -0,0 +1,23 @@
+<?php
+
+class HttpdnsGetRequest
+{
+ private $apiParas = array();
+
+ public function getApiMethodName()
+ {
+ return "taobao.httpdns.get";
+ }
+
+ public function getApiParas()
+ {
+ return $this->apiParas;
+ }
+
+ public function check(){}
+
+ public function putOtherTextParam($key, $value) {
+ $this->apiParas[$key] = $value;
+ $this->$key = $value;
+ }
+}
diff --git a/Library/Alidayu/SDK/RequestCheckUtil.php b/Library/Alidayu/SDK/RequestCheckUtil.php
new file mode 100644
index 0000000..5ec32ab
--- /dev/null
+++ b/Library/Alidayu/SDK/RequestCheckUtil.php
@@ -0,0 +1,107 @@
+<?php
+/**
+ * API��������������
+ * ������API����������������������������������
+ *
+ **/
+class RequestCheckUtil
+{
+ /**
+ * �������� fieldName ����$value����
+ *
+ **/
+ public static function checkNotNull($value,$fieldName) {
+
+ if(self::checkEmpty($value)){
+ throw new Exception("client-check-error:Missing Required Arguments: " .$fieldName , 40);
+ }
+ }
+
+ /**
+ * ��������fieldName����value ������
+ *
+ **/
+ public static function checkMaxLength($value,$maxLength,$fieldName){
+ if(!self::checkEmpty($value) && mb_strlen($value , "UTF-8") > $maxLength){
+ throw new Exception("client-check-error:Invalid Arguments:the length of " .$fieldName . " can not be larger than " . $maxLength . "." , 41);
+ }
+ }
+
+ /**
+ * ��������fieldName����value��������������
+ *
+ **/
+ public static function checkMaxListSize($value,$maxSize,$fieldName) {
+
+ if(self::checkEmpty($value))
+ return ;
+
+ $list=preg_split("/,/",$value);
+ if(count($list) > $maxSize){
+ throw new Exception("client-check-error:Invalid Arguments:the listsize(the string split by \",\") of ". $fieldName . " must be less than " . $maxSize . " ." , 41);
+ }
+ }
+
+ /**
+ * ��������fieldName����value ��������
+ *
+ **/
+ public static function checkMaxValue($value,$maxValue,$fieldName){
+
+ if(self::checkEmpty($value))
+ return ;
+
+ self::checkNumeric($value,$fieldName);
+
+ if($value > $maxValue){
+ throw new Exception("client-check-error:Invalid Arguments:the value of " . $fieldName . " can not be larger than " . $maxValue ." ." , 41);
+ }
+ }
+
+ /**
+ * ��������fieldName����value ��������
+ *
+ **/
+ public static function checkMinValue($value,$minValue,$fieldName) {
+
+ if(self::checkEmpty($value))
+ return ;
+
+ self::checkNumeric($value,$fieldName);
+
+ if($value < $minValue){
+ throw new Exception("client-check-error:Invalid Arguments:the value of " . $fieldName . " can not be less than " . $minValue . " ." , 41);
+ }
+ }
+
+ /**
+ * ��������fieldName����value������number
+ *
+ **/
+ protected static function checkNumeric($value,$fieldName) {
+ if(!is_numeric($value))
+ throw new Exception("client-check-error:Invalid Arguments:the value of " . $fieldName . " is not number : " . $value . " ." , 41);
+ }
+
+ /**
+ * ����$value��������
+ * if not set ,return true;
+ * if is null , return true;
+ *
+ *
+ **/
+ public static function checkEmpty($value) {
+ if(!isset($value))
+ return true ;
+ if($value === null )
+ return true;
+ if(is_array($value) && count($value) == 0)
+ return true;
+ if(is_string($value) &&trim($value) === "")
+ return true;
+
+ return false;
+ }
+
+}
+?>
\ No newline at end of file
diff --git a/Library/Alidayu/SDK/ResultSet.php b/Library/Alidayu/SDK/ResultSet.php
new file mode 100644
index 0000000..6df5375
--- /dev/null
+++ b/Library/Alidayu/SDK/ResultSet.php
@@ -0,0 +1,21 @@
+<?php
+/**
+ * ������������������
+ *
+ * @author auto create
+ * @since 1.0, 2015-01-20
+ */
+class ResultSet
+{
+
+ /**
+ * ������������������
+ **/
+ public $code;
+
+ /**
+ * ���������������������
+ **/
+ public $msg;
+
+}
diff --git a/Library/Alidayu/SDK/SpiUtils.php b/Library/Alidayu/SDK/SpiUtils.php
new file mode 100644
index 0000000..be2e65c
--- /dev/null
+++ b/Library/Alidayu/SDK/SpiUtils.php
@@ -0,0 +1,214 @@
+<?php
+class SpiUtils{
+ private static $top_sign_list = "HTTP_TOP_SIGN_LIST";
+ private static $timestamp = "timestamp";
+ private static $header_real_ip = array("X_Real_IP", "X_Forwarded_For", "Proxy_Client_IP",
+ "WL_Proxy_Client_IP", "HTTP_CLIENT_IP", "HTTP_X_FORWARDED_FOR");
+ /**
+ * ������SPI������������������������������GET������������������������������������POST���������
+ *
+ * @param request ������������
+ * @param secret app���������secret
+ * @return true������������������false������������������
+ */
+ public static function checkSign4FormRequest($secret){
+ return self::checkSign(null,null,$secret);
+ }
+
+ /**
+ * ������SPI������������������������������������xml/json������������������������POST���������
+ *
+ * @param request ������������
+ * @param body ������������������������
+ * @param secret app���������secret
+ * @return true������������������false������������������
+ */
+ public static function checkSign4TextRequest($body,$secret){
+ return self::checkSign(null,$body,$secret);
+ }
+
+ /**
+ * ������SPI������������������������������������������POST���������
+ *
+ * @param request ������������
+ * @param form ������������������������������������������������������map������
+ * @param secret app���������secret
+ * @return true������������������false������������������
+ */
+ public static function checkSign4FileRequest($form, $secret){
+ return self::checkSign($form, null, $secret);
+ }
+
+ private static function checkSign($form, $body, $secret) {
+ $params = array();
+ // 1. ������header������
+ $headerMap = self::getHeaderMap();
+ foreach ($headerMap as $k => $v){
+ $params[$k] = $v ;
+ }
+
+ // 2. ������url������
+ $queryMap = self::getQueryMap();
+ foreach ($queryMap as $k => $v){
+ $params[$k] = $v ;
+ }
+
+ // 3. ������form������
+ if ($form == null && $body == null) {
+ $formMap = self::getFormMap();
+ foreach ($formMap as $k => $v){
+ $params[$k] = $v ;
+ }
+ } else if ($form != null) {
+ foreach ($form as $k => $v){
+ $params[$k] = $v ;
+ }
+ }
+
+ if($body == null){
+ $body = file_get_contents('php://input');
+ }
+
+ $remoteSign = $queryMap["sign"];
+ $localSign = self::sign($params, $body, $secret);
+ if (strcmp($remoteSign, $localSign) == 0) {
+ return true;
+ } else {
+ $paramStr = self::getParamStrFromMap($params);
+ self::logCommunicationError($remoteSign,$localSign,$paramStr,$body);
+ return false;
+ }
+ }
+
+ private static function getHeaderMap() {
+ $headerMap = array();
+ $signList = $_SERVER['HTTP_TOP_SIGN_LIST']; // ������������������������������������
+ $signList = trim($signList);
+ if (strlen($signList) > 0){
+ $params = split(",", $signList);
+ foreach ($_SERVER as $k => $v){
+ if (substr($k, 0, 5) == 'HTTP_'){
+ foreach($params as $kk){
+ $upperkey = strtoupper($kk);
+ if(self::endWith($k,$upperkey)){
+ $headerMap[$kk] = $v;
+ }
+ }
+ }
+ }
+ }
+ return $headerMap;
+ }
+
+ private static function getQueryMap(){
+ $queryStr = $_SERVER["QUERY_STRING"];
+ $resultArray = array();
+ foreach (explode('&', $queryStr) as $pair) {
+ list($key, $value) = explode('=', $pair);
+ if (strpos($key, '.') !== false) {
+ list($subKey, $subVal) = explode('.', $key);
+
+ if (preg_match('/(?P<name>\w+)\[(?P<index>\w+)\]/', $subKey, $matches)) {
+ $resultArray[$matches['name']][$matches['index']][$subVal] = $value;
+ } else {
+ $resultArray[$subKey][$subVal] = urldecode($value);
+ }
+ } else {
+ $resultArray[$key] = urldecode($value);
+ }
+ }
+ return $resultArray;
+ }
+
+ private static function checkRemoteIp(){
+ $remoteIp = $_SERVER["REMOTE_ADDR"];
+ foreach ($header_real_ip as $k){
+ $realIp = $_SERVER[$k];
+ $realIp = trim($realIp);
+ if(strlen($realIp) > 0 && strcasecmp("unknown",$realIp)){
+ $remoteIp = $realIp;
+ break;
+ }
+ }
+ return self::startsWith($remoteIp,"140.205.144.") || $this->startsWith($remoteIp,"40.205.145.");
+ }
+
+ private static function getFormMap(){
+ $resultArray = array();
+ foreach($_POST as $key=>$v) {
+ $resultArray[$k] = $v ;
+ }
+ return $resultArray ;
+ }
+
+ private static function startsWith($haystack, $needle) {
+ return $needle === "" || strpos($haystack, $needle) === 0;
+ }
+
+ private static function endWith($haystack, $needle) {
+ $length = strlen($needle);
+ if($length == 0)
+ {
+ return true;
+ }
+ return (substr($haystack, -$length) === $needle);
+ }
+
+ private static function checkTimestamp(){
+ $ts = $_POST['timestamp'];
+ if($ts){
+ $clientTimestamp = strtotime($ts);
+ $current = $_SERVER['REQUEST_TIME'];
+ return ($current - $clientTimestamp) <= 5*60*1000;
+ }else{
+ return false;
+ }
+ }
+
+ private static function getParamStrFromMap($params){
+ ksort($params);
+ $stringToBeSigned = "";
+ foreach ($params as $k => $v)
+ {
+ if(strcmp("sign", $k) != 0)
+ {
+ $stringToBeSigned .= "$k$v";
+ }
+ }
+ unset($k, $v);
+ return $stringToBeSigned;
+ }
+
+ private static function sign($params,$body,$secret){
+ ksort($params);
+
+ $stringToBeSigned = $secret;
+ $stringToBeSigned .= self::getParamStrFromMap($params);
+
+ if($body)
+ $stringToBeSigned .= $body;
+ $stringToBeSigned .= $secret;
+ return strtoupper(md5($stringToBeSigned));
+ }
+
+ protected static function logCommunicationError($remoteSign, $localSign, $paramStr, $body)
+ {
+ $localIp = isset($_SERVER["SERVER_ADDR"]) ? $_SERVER["SERVER_ADDR"] : "CLI";
+ $logger = new TopLogger;
+ $logger->conf["log_file"] = rtrim(TOP_SDK_WORK_DIR, '\\/') . '/' . "logs/top_comm_err_". date("Y-m-d") . ".log";
+ $logger->conf["separator"] = "^_^";
+ $logData = array(
+ "checkTopSign error" ,
+ "remoteSign=".$remoteSign ,
+ "localSign=".$localSign ,
+ "paramStr=".$paramStr ,
+ "body=".$body
+ );
+ $logger->log($logData);
+ }
+ private static function clear_blank($str, $glue='')
+ {
+ $replace = array(" ", "\r", "\n", "\t"); return str_replace($replace, $glue, $str);
+ }
+}
+?>
\ No newline at end of file
diff --git a/Library/Alidayu/SDK/TopClient.php b/Library/Alidayu/SDK/TopClient.php
new file mode 100644
index 0000000..fa7f4ea
--- /dev/null
+++ b/Library/Alidayu/SDK/TopClient.php
@@ -0,0 +1,375 @@
+<?php
+class TopClient
+{
+ public $appkey;
+
+ public $secretKey;
+
+ public $gatewayUrl = "http://gw.api.taobao.com/router/rest";
+
+ public $format = "xml";
+
+ public $connectTimeout;
+
+ public $readTimeout;
+
+ /** ������������������check**/
+ public $checkRequest = true;
+
+ protected $signMethod = "md5";
+
+ protected $apiVersion = "2.0";
+
+ protected $sdkVersion = "top-sdk-php-20151012";
+
+ public function __construct($appkey = "",$secretKey = ""){
+ $this->appkey = $appkey;
+ $this->secretKey = $secretKey ;
+ }
+
+ protected function generateSign($params)
+ {
+ ksort($params);
+
+ $stringToBeSigned = $this->secretKey;
+ foreach ($params as $k => $v)
+ {
+ if(is_string($v) && "@" != substr($v, 0, 1))
+ {
+ $stringToBeSigned .= "$k$v";
+ }
+ }
+ unset($k, $v);
+ $stringToBeSigned .= $this->secretKey;
+
+ return strtoupper(md5($stringToBeSigned));
+ }
+
+ public function curl($url, $postFields = null)
+ {
+ $ch = curl_init();
+ curl_setopt($ch, CURLOPT_URL, $url);
+ curl_setopt($ch, CURLOPT_FAILONERROR, false);
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
+ if ($this->readTimeout) {
+ curl_setopt($ch, CURLOPT_TIMEOUT, $this->readTimeout);
+ }
+ if ($this->connectTimeout) {
+ curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $this->connectTimeout);
+ }
+ curl_setopt ( $ch, CURLOPT_USERAGENT, "top-sdk-php" );
+ //https ������
+ if(strlen($url) > 5 && strtolower(substr($url,0,5)) == "https" ) {
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
+ curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
+ }
+
+ if (is_array($postFields) && 0 < count($postFields))
+ {
+ $postBodyString = "";
+ $postMultipart = false;
+ foreach ($postFields as $k => $v)
+ {
+ if(!is_string($v))
+ continue ;
+
+ if("@" != substr($v, 0, 1))//���������������������������
+ {
+ $postBodyString .= "$k=" . urlencode($v) . "&";
+ }
+ else//���������������multipart/form-data������������www-form-urlencoded
+ {
+ $postMultipart = true;
+ if(class_exists('\CURLFile')){
+ $postFields[$k] = new \CURLFile(substr($v, 1));
+ }
+ }
+ }
+ unset($k, $v);
+ curl_setopt($ch, CURLOPT_POST, true);
+ if ($postMultipart)
+ {
+ if (class_exists('\CURLFile')) {
+ curl_setopt($ch, CURLOPT_SAFE_UPLOAD, true);
+ } else {
+ if (defined('CURLOPT_SAFE_UPLOAD')) {
+ curl_setopt($ch, CURLOPT_SAFE_UPLOAD, false);
+ }
+ }
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $postFields);
+ }
+ else
+ {
+ $header = array("content-type: application/x-www-form-urlencoded; charset=UTF-8");
+ curl_setopt($ch,CURLOPT_HTTPHEADER,$header);
+ curl_setopt($ch, CURLOPT_POSTFIELDS, substr($postBodyString,0,-1));
+ }
+ }
+ $reponse = curl_exec($ch);
+
+ if (curl_errno($ch))
+ {
+ throw new Exception(curl_error($ch),0);
+ }
+ else
+ {
+ $httpStatusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
+ if (200 !== $httpStatusCode)
+ {
+ throw new Exception($reponse,$httpStatusCode);
+ }
+ }
+ curl_close($ch);
+ return $reponse;
+ }
+ public function curl_with_memory_file($url, $postFields = null, $fileFields = null)
+ {
+ $ch = curl_init();
+ curl_setopt($ch, CURLOPT_URL, $url);
+ curl_setopt($ch, CURLOPT_FAILONERROR, false);
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
+ if ($this->readTimeout) {
+ curl_setopt($ch, CURLOPT_TIMEOUT, $this->readTimeout);
+ }
+ if ($this->connectTimeout) {
+ curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $this->connectTimeout);
+ }
+ curl_setopt ( $ch, CURLOPT_USERAGENT, "top-sdk-php" );
+ //https ������
+ if(strlen($url) > 5 && strtolower(substr($url,0,5)) == "https" ) {
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
+ curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
+ }
+ //���������������
+ $delimiter = '-------------' . uniqid();
+ //������post������������������������������������
+ $data = '';
+ if($postFields != null){
+ foreach ($postFields as $name => $content) {
+ $data .= "--" . $delimiter . "\r\n";
+ $data .= 'Content-Disposition: form-data; name="' . $name . '"';
+ //multipart/form-data ���������urlencode��������� http:stackoverflow.com/questions/6603928/should-i-url-encode-post-data
+ $data .= "\r\n\r\n" . $content . "\r\n";
+ }
+ unset($name,$content);
+ }
+
+ //���������������������������������������
+ if($fileFields != null){
+ foreach ($fileFields as $name => $file) {
+ $data .= "--" . $delimiter . "\r\n";
+ $data .= 'Content-Disposition: form-data; name="' . $name . '"; filename="' . $file['name'] . "\" \r\n";
+ $data .= 'Content-Type: ' . $file['type'] . "\r\n\r\n";//���������������������
+
+ $data .= $file['content'] . "\r\n";
+ }
+ unset($name,$file);
+ }
+ //������������������������
+ $data .= "--" . $delimiter . "--";
+
+ curl_setopt($ch, CURLOPT_POST, true);
+ curl_setopt($ch, CURLOPT_HTTPHEADER , array(
+ 'Content-Type: multipart/form-data; boundary=' . $delimiter,
+ 'Content-Length: ' . strlen($data))
+ );
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
+
+ $reponse = curl_exec($ch);
+ unset($data);
+
+ if (curl_errno($ch))
+ {
+ throw new Exception(curl_error($ch),0);
+ }
+ else
+ {
+ $httpStatusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
+ if (200 !== $httpStatusCode)
+ {
+ throw new Exception($reponse,$httpStatusCode);
+ }
+ }
+ curl_close($ch);
+ return $reponse;
+ }
+
+ protected function logCommunicationError($apiName, $requestUrl, $errorCode, $responseTxt)
+ {
+ $localIp = isset($_SERVER["SERVER_ADDR"]) ? $_SERVER["SERVER_ADDR"] : "CLI";
+ $logger = new TopLogger;
+ $logger->conf["log_file"] = rtrim(TOP_SDK_WORK_DIR, '\\/') . '/' . "logs/top_comm_err_" . $this->appkey . "_" . date("Y-m-d") . ".log";
+ $logger->conf["separator"] = "^_^";
+ $logData = array(
+ date("Y-m-d H:i:s"),
+ $apiName,
+ $this->appkey,
+ $localIp,
+ PHP_OS,
+ $this->sdkVersion,
+ $requestUrl,
+ $errorCode,
+ str_replace("\n","",$responseTxt)
+ );
+ $logger->log($logData);
+ }
+
+ public function execute($request, $session = null,$bestUrl = null)
+ {
+ $result = new ResultSet();
+ if($this->checkRequest) {
+ try {
+ $request->check();
+ } catch (Exception $e) {
+
+ $result->code = $e->getCode();
+ $result->msg = $e->getMessage();
+ return $result;
+ }
+ }
+ //������������������
+ $sysParams["app_key"] = $this->appkey;
+ $sysParams["v"] = $this->apiVersion;
+ $sysParams["format"] = $this->format;
+ $sysParams["sign_method"] = $this->signMethod;
+ $sysParams["method"] = $request->getApiMethodName();
+ $sysParams["timestamp"] = date("Y-m-d H:i:s");
+ if (null != $session)
+ {
+ $sysParams["session"] = $session;
+ }
+ $apiParams = array();
+ //������������������
+ $apiParams = $request->getApiParas();
+
+
+ //������������������GET���������
+ if($bestUrl){
+ $requestUrl = $bestUrl."?";
+ $sysParams["partner_id"] = $this->getClusterTag();
+ }else{
+ $requestUrl = $this->gatewayUrl."?";
+ $sysParams["partner_id"] = $this->sdkVersion;
+ }
+ //������
+ $sysParams["sign"] = $this->generateSign(array_merge($apiParams, $sysParams));
+
+ foreach ($sysParams as $sysParamKey => $sysParamValue)
+ {
+ // if(strcmp($sysParamKey,"timestamp") != 0)
+ $requestUrl .= "$sysParamKey=" . urlencode($sysParamValue) . "&";
+ }
+
+ $fileFields = array();
+ foreach ($apiParams as $key => $value) {
+ if(is_array($value) && array_key_exists('type',$value) && array_key_exists('content',$value) ){
+ $value['name'] = $key;
+ $fileFields[$key] = $value;
+ unset($apiParams[$key]);
+ }
+ }
+
+ // $requestUrl .= "timestamp=" . urlencode($sysParams["timestamp"]) . "&";
+ $requestUrl = substr($requestUrl, 0, -1);
+
+ //������HTTP������
+ try
+ {
+ if(count($fileFields) > 0){
+ $resp = $this->curl_with_memory_file($requestUrl, $apiParams, $fileFields);
+ }else{
+ $resp = $this->curl($requestUrl, $apiParams);
+ }
+ }
+ catch (Exception $e)
+ {
+ $this->logCommunicationError($sysParams["method"],$requestUrl,"HTTP_ERROR_" . $e->getCode(),$e->getMessage());
+ $result->code = $e->getCode();
+ $result->msg = $e->getMessage();
+ return $result;
+ }
+
+ unset($apiParams);
+ unset($fileFields);
+ //������TOP������������
+ $respWellFormed = false;
+ if ("json" == $this->format)
+ {
+ $respObject = json_decode($resp);
+ if (null !== $respObject)
+ {
+ $respWellFormed = true;
+ foreach ($respObject as $propKey => $propValue)
+ {
+ $respObject = $propValue;
+ }
+ }
+ }
+ else if("xml" == $this->format)
+ {
+ $respObject = @simplexml_load_string($resp);
+ if (false !== $respObject)
+ {
+ $respWellFormed = true;
+ }
+ }
+
+ //���������HTTP������������������JSON������XML���������������������
+ if (false === $respWellFormed)
+ {
+ $this->logCommunicationError($sysParams["method"],$requestUrl,"HTTP_RESPONSE_NOT_WELL_FORMED",$resp);
+ $result->code = 0;
+ $result->msg = "HTTP_RESPONSE_NOT_WELL_FORMED";
+ return $result;
+ }
+
+ //������TOP���������������������������������������������������
+ if (isset($respObject->code))
+ {
+ $logger = new TopLogger;
+ $logger->conf["log_file"] = rtrim(TOP_SDK_WORK_DIR, '\\/') . '/' . "logs/top_biz_err_" . $this->appkey . "_" . date("Y-m-d") . ".log";
+ $logger->log(array(
+ date("Y-m-d H:i:s"),
+ $resp
+ ));
+ }
+ return $respObject;
+ }
+
+ public function exec($paramsArray)
+ {
+ if (!isset($paramsArray["method"]))
+ {
+ trigger_error("No api name passed");
+ }
+ $inflector = new LtInflector;
+ $inflector->conf["separator"] = ".";
+ $requestClassName = ucfirst($inflector->camelize(substr($paramsArray["method"], 7))) . "Request";
+ if (!class_exists($requestClassName))
+ {
+ trigger_error("No such api: " . $paramsArray["method"]);
+ }
+
+ $session = isset($paramsArray["session"]) ? $paramsArray["session"] : null;
+
+ $req = new $requestClassName;
+ foreach($paramsArray as $paraKey => $paraValue)
+ {
+ $inflector->conf["separator"] = "_";
+ $setterMethodName = $inflector->camelize($paraKey);
+ $inflector->conf["separator"] = ".";
+ $setterMethodName = "set" . $inflector->camelize($setterMethodName);
+ if (method_exists($req, $setterMethodName))
+ {
+ $req->$setterMethodName($paraValue);
+ }
+ }
+ return $this->execute($req, $session);
+ }
+
+ private function getClusterTag()
+ {
+ return substr($this->sdkVersion,0,11)."-cluster".substr($this->sdkVersion,11);
+ }
+}
diff --git a/Library/Alidayu/SDK/TopLogger.php b/Library/Alidayu/SDK/TopLogger.php
new file mode 100644
index 0000000..536330a
--- /dev/null
+++ b/Library/Alidayu/SDK/TopLogger.php
@@ -0,0 +1,43 @@
+<?php
+class TopLogger
+{
+ public $conf = array(
+ "separator" => "\t",
+ "log_file" => ""
+ );
+
+ private $fileHandle;
+
+ protected function getFileHandle()
+ {
+ if (null === $this->fileHandle)
+ {
+ if (empty($this->conf["log_file"]))
+ {
+ trigger_error("no log file spcified.");
+ }
+ $logDir = dirname($this->conf["log_file"]);
+ if (!is_dir($logDir))
+ {
+ mkdir($logDir, 0777, true);
+ }
+ $this->fileHandle = fopen($this->conf["log_file"], "a");
+ }
+ return $this->fileHandle;
+ }
+
+ public function log($logData)
+ {
+ if ("" == $logData || array() == $logData)
+ {
+ return false;
+ }
+ if (is_array($logData))
+ {
+ $logData = implode($this->conf["separator"], $logData);
+ }
+ $logData = $logData. "\n";
+ fwrite($this->getFileHandle(), $logData);
+ }
+}
+?>
\ No newline at end of file
diff --git a/Library/Alidayu/SDK/domain/Area.php b/Library/Alidayu/SDK/domain/Area.php
new file mode 100644
index 0000000..6e5b7de
--- /dev/null
+++ b/Library/Alidayu/SDK/domain/Area.php
@@ -0,0 +1,35 @@
+<?php
+
+/**
+ * ������������������
+ * @author auto create
+ */
+class Area
+{
+
+ /**
+ * ������������������������.������:http://www.stats.gov.cn/tjbz/xzqhdm/t20120105_402777427.htm
+ **/
+ public $id;
+
+ /**
+ * ������������.������������,���������,���������,���������area_id ���������������������������������.
+ **/
+ public $name;
+
+ /**
+ * ���������������������.���������������area_id���110100,���������������������������������,������������������parent_id������������������area_id.
+ **/
+ public $parent_id;
+
+ /**
+ * ������������.area������ 1:country/������;2:province/���/���������/���������;3:city/������(���������������������);4:district/���/���(���������)/���;abroad:������. ������������������area_type = 2,���������������������������������,������������������area_type = 4.
+ **/
+ public $type;
+
+ /**
+ * ���������������������������
+ **/
+ public $zip;
+}
+?>
\ No newline at end of file
diff --git a/Library/Alidayu/SDK/domain/BizResult.php b/Library/Alidayu/SDK/domain/BizResult.php
new file mode 100644
index 0000000..4971c20
--- /dev/null
+++ b/Library/Alidayu/SDK/domain/BizResult.php
@@ -0,0 +1,30 @@
+<?php
+
+/**
+ * ������������������
+ * @author auto create
+ */
+class BizResult
+{
+
+ /**
+ * ���������
+ **/
+ public $err_code;
+
+ /**
+ * ������������
+ **/
+ public $model;
+
+ /**
+ * ������������������
+ **/
+ public $msg;
+
+ /**
+ * true���������������false������������
+ **/
+ public $success;
+}
+?>
\ No newline at end of file
diff --git a/Library/Alidayu/SDK/domain/FcPartnerSmsDetailDto.php b/Library/Alidayu/SDK/domain/FcPartnerSmsDetailDto.php
new file mode 100644
index 0000000..8ccee78
--- /dev/null
+++ b/Library/Alidayu/SDK/domain/FcPartnerSmsDetailDto.php
@@ -0,0 +1,50 @@
+<?php
+
+/**
+ * 1
+ * @author auto create
+ */
+class FcPartnerSmsDetailDto
+{
+
+ /**
+ * ������������������
+ **/
+ public $extend;
+
+ /**
+ * ������������������
+ **/
+ public $rec_num;
+
+ /**
+ * ���������������
+ **/
+ public $result_code;
+
+ /**
+ * ������������
+ **/
+ public $sms_code;
+
+ /**
+ * ������������������
+ **/
+ public $sms_content;
+
+ /**
+ * ������������������
+ **/
+ public $sms_receiver_time;
+
+ /**
+ * ������������������
+ **/
+ public $sms_send_time;
+
+ /**
+ * ������������ 1������������������2������������������3���������������
+ **/
+ public $sms_status;
+}
+?>
\ No newline at end of file
diff --git a/Library/Alidayu/SDK/domain/KfcSearchResult.php b/Library/Alidayu/SDK/domain/KfcSearchResult.php
new file mode 100644
index 0000000..f8aedbf
--- /dev/null
+++ b/Library/Alidayu/SDK/domain/KfcSearchResult.php
@@ -0,0 +1,29 @@
+<?php
+
+/**
+ * KFC ���������������������������
+ * @author auto create
+ */
+class KfcSearchResult
+{
+
+ /**
+ * ���������������������
+������������B���������������������������������������������������*������content������������������������������������
+���������������content���������null
+ **/
+ public $content;
+
+ /**
+ * ���������������������������������������null���������A���B���C���D���
+������������������������������������null���������������A���B���C���D���������������
+A���B���C���D������������������������������������������
+ **/
+ public $level;
+
+ /**
+ * ������������������������,���������������true.
+ **/
+ public $matched;
+}
+?>
\ No newline at end of file
diff --git a/Library/Alidayu/SDK/domain/Result.php b/Library/Alidayu/SDK/domain/Result.php
new file mode 100644
index 0000000..75d0733
--- /dev/null
+++ b/Library/Alidayu/SDK/domain/Result.php
@@ -0,0 +1,30 @@
+<?php
+
+/**
+ * ���
+ * @author auto create
+ */
+class Result
+{
+
+ /**
+ * ���������
+ **/
+ public $code;
+
+ /**
+ * ���
+ **/
+ public $model;
+
+ /**
+ * ������
+ **/
+ public $msg;
+
+ /**
+ * ������
+ **/
+ public $success;
+}
+?>
\ No newline at end of file
diff --git a/Library/Alidayu/SDK/domain/Subtask.php b/Library/Alidayu/SDK/domain/Subtask.php
new file mode 100644
index 0000000..d36f18f
--- /dev/null
+++ b/Library/Alidayu/SDK/domain/Subtask.php
@@ -0,0 +1,25 @@
+<?php
+
+/**
+ * ������������������������������������
+ * @author auto create
+ */
+class Subtask
+{
+
+ /**
+ * ���������������������������������true���������������������������������������������������������������������������sub_task_result������false������������������������������������������������������������������������sub_task_result���������������sub_code���sub_msg���
+ **/
+ public $is_success;
+
+ /**
+ * ������������������������������������json������������key:value���������
+ **/
+ public $sub_task_request;
+
+ /**
+ * ������������������������������json������������key:value������������������������api���������������������������������������������������������������������������������������������������������������{���trade���:{"tid":123456,"seller_nick":"������������"}}���������������������������������������{"sub_code":"isv.trade-not-exist","sub_msg":"���������������������"}
+ **/
+ public $sub_task_result;
+}
+?>
\ No newline at end of file
diff --git a/Library/Alidayu/SDK/domain/Task.php b/Library/Alidayu/SDK/domain/Task.php
new file mode 100644
index 0000000..4cb9050
--- /dev/null
+++ b/Library/Alidayu/SDK/domain/Task.php
@@ -0,0 +1,52 @@
+<?php
+
+/**
+ * ������������������������
+ * @author auto create
+ */
+class Task
+{
+
+ /**
+ * ���������������MD5������������������������������������������������������������������������������
+ **/
+ public $check_code;
+
+ /**
+ * ������������������
+ **/
+ public $created;
+
+ /**
+ * ������������������������������������������������������������������������������������������������������������������������subtasks������������������
+���������������������������������������������������������������������������������������������
+���������������������������������������������������������������������������.zip���������
+ **/
+ public $download_url;
+
+ /**
+ * ���������������������api���������
+ **/
+ public $method;
+
+ /**
+ * ������������������������������������
+ **/
+ public $schedule;
+
+ /**
+ * ���������������������������new���������������������������doing������������������done���������������������
+ **/
+ public $status;
+
+ /**
+ * ���������������������������������������������������������������������������������������������������������������������������������������������
+ **/
+ public $subtasks;
+
+ /**
+ * ������������id���������������������������������������id���
+ **/
+ public $task_id;
+}
+?>
\ No newline at end of file
diff --git a/Library/Alidayu/SDK/request/AlibabaAliqinFcFlowChargeProvinceRequest.php b/Library/Alidayu/SDK/request/AlibabaAliqinFcFlowChargeProvinceRequest.php
new file mode 100644
index 0000000..78bb189
--- /dev/null
+++ b/Library/Alidayu/SDK/request/AlibabaAliqinFcFlowChargeProvinceRequest.php
@@ -0,0 +1,98 @@
+<?php
+/**
+ * TOP API: alibaba.aliqin.fc.flow.charge.province request
+ *
+ * @author auto create
+ * @since 1.0, 2016.03.30
+ */
+class AlibabaAliqinFcFlowChargeProvinceRequest
+{
+ /**
+ * ���������������������
+ **/
+ private $grade;
+
+ /**
+ * ���������������
+ **/
+ private $outRechargeId;
+
+ /**
+ * ���������
+ **/
+ private $phoneNum;
+
+ /**
+ * ������������
+ **/
+ private $reason;
+
+ private $apiParas = array();
+
+ public function setGrade($grade)
+ {
+ $this->grade = $grade;
+ $this->apiParas["grade"] = $grade;
+ }
+
+ public function getGrade()
+ {
+ return $this->grade;
+ }
+
+ public function setOutRechargeId($outRechargeId)
+ {
+ $this->outRechargeId = $outRechargeId;
+ $this->apiParas["out_recharge_id"] = $outRechargeId;
+ }
+
+ public function getOutRechargeId()
+ {
+ return $this->outRechargeId;
+ }
+
+ public function setPhoneNum($phoneNum)
+ {
+ $this->phoneNum = $phoneNum;
+ $this->apiParas["phone_num"] = $phoneNum;
+ }
+
+ public function getPhoneNum()
+ {
+ return $this->phoneNum;
+ }
+
+ public function setReason($reason)
+ {
+ $this->reason = $reason;
+ $this->apiParas["reason"] = $reason;
+ }
+
+ public function getReason()
+ {
+ return $this->reason;
+ }
+
+ public function getApiMethodName()
+ {
+ return "alibaba.aliqin.fc.flow.charge.province";
+ }
+
+ public function getApiParas()
+ {
+ return $this->apiParas;
+ }
+
+ public function check()
+ {
+
+ RequestCheckUtil::checkNotNull($this->grade,"grade");
+ RequestCheckUtil::checkNotNull($this->outRechargeId,"outRechargeId");
+ RequestCheckUtil::checkNotNull($this->phoneNum,"phoneNum");
+ }
+
+ public function putOtherTextParam($key, $value) {
+ $this->apiParas[$key] = $value;
+ $this->$key = $value;
+ }
+}
diff --git a/Library/Alidayu/SDK/request/AlibabaAliqinFcFlowChargeRequest.php b/Library/Alidayu/SDK/request/AlibabaAliqinFcFlowChargeRequest.php
new file mode 100644
index 0000000..c67063c
--- /dev/null
+++ b/Library/Alidayu/SDK/request/AlibabaAliqinFcFlowChargeRequest.php
@@ -0,0 +1,98 @@
+<?php
+/**
+ * TOP API: alibaba.aliqin.fc.flow.charge request
+ *
+ * @author auto create
+ * @since 1.0, 2016.03.30
+ */
+class AlibabaAliqinFcFlowChargeRequest
+{
+ /**
+ * ���������������������
+ **/
+ private $grade;
+
+ /**
+ * ���������������
+ **/
+ private $outRechargeId;
+
+ /**
+ * ���������
+ **/
+ private $phoneNum;
+
+ /**
+ * ������������
+ **/
+ private $reason;
+
+ private $apiParas = array();
+
+ public function setGrade($grade)
+ {
+ $this->grade = $grade;
+ $this->apiParas["grade"] = $grade;
+ }
+
+ public function getGrade()
+ {
+ return $this->grade;
+ }
+
+ public function setOutRechargeId($outRechargeId)
+ {
+ $this->outRechargeId = $outRechargeId;
+ $this->apiParas["out_recharge_id"] = $outRechargeId;
+ }
+
+ public function getOutRechargeId()
+ {
+ return $this->outRechargeId;
+ }
+
+ public function setPhoneNum($phoneNum)
+ {
+ $this->phoneNum = $phoneNum;
+ $this->apiParas["phone_num"] = $phoneNum;
+ }
+
+ public function getPhoneNum()
+ {
+ return $this->phoneNum;
+ }
+
+ public function setReason($reason)
+ {
+ $this->reason = $reason;
+ $this->apiParas["reason"] = $reason;
+ }
+
+ public function getReason()
+ {
+ return $this->reason;
+ }
+
+ public function getApiMethodName()
+ {
+ return "alibaba.aliqin.fc.flow.charge";
+ }
+
+ public function getApiParas()
+ {
+ return $this->apiParas;
+ }
+
+ public function check()
+ {
+
+ RequestCheckUtil::checkNotNull($this->grade,"grade");
+ RequestCheckUtil::checkNotNull($this->outRechargeId,"outRechargeId");
+ RequestCheckUtil::checkNotNull($this->phoneNum,"phoneNum");
+ }
+
+ public function putOtherTextParam($key, $value) {
+ $this->apiParas[$key] = $value;
+ $this->$key = $value;
+ }
+}
diff --git a/Library/Alidayu/SDK/request/AlibabaAliqinFcFlowGradeRequest.php b/Library/Alidayu/SDK/request/AlibabaAliqinFcFlowGradeRequest.php
new file mode 100644
index 0000000..3f138ef
--- /dev/null
+++ b/Library/Alidayu/SDK/request/AlibabaAliqinFcFlowGradeRequest.php
@@ -0,0 +1,32 @@
+<?php
+/**
+ * TOP API: alibaba.aliqin.fc.flow.grade request
+ *
+ * @author auto create
+ * @since 1.0, 2016.03.30
+ */
+class AlibabaAliqinFcFlowGradeRequest
+{
+
+ private $apiParas = array();
+
+ public function getApiMethodName()
+ {
+ return "alibaba.aliqin.fc.flow.grade";
+ }
+
+ public function getApiParas()
+ {
+ return $this->apiParas;
+ }
+
+ public function check()
+ {
+
+ }
+
+ public function putOtherTextParam($key, $value) {
+ $this->apiParas[$key] = $value;
+ $this->$key = $value;
+ }
+}
diff --git a/Library/Alidayu/SDK/request/AlibabaAliqinFcFlowQueryRequest.php b/Library/Alidayu/SDK/request/AlibabaAliqinFcFlowQueryRequest.php
new file mode 100644
index 0000000..64e1f50
--- /dev/null
+++ b/Library/Alidayu/SDK/request/AlibabaAliqinFcFlowQueryRequest.php
@@ -0,0 +1,47 @@
+<?php
+/**
+ * TOP API: alibaba.aliqin.fc.flow.query request
+ *
+ * @author auto create
+ * @since 1.0, 2016.03.30
+ */
+class AlibabaAliqinFcFlowQueryRequest
+{
+ /**
+ * ���������������
+ **/
+ private $outId;
+
+ private $apiParas = array();
+
+ public function setOutId($outId)
+ {
+ $this->outId = $outId;
+ $this->apiParas["out_id"] = $outId;
+ }
+
+ public function getOutId()
+ {
+ return $this->outId;
+ }
+
+ public function getApiMethodName()
+ {
+ return "alibaba.aliqin.fc.flow.query";
+ }
+
+ public function getApiParas()
+ {
+ return $this->apiParas;
+ }
+
+ public function check()
+ {
+
+ }
+
+ public function putOtherTextParam($key, $value) {
+ $this->apiParas[$key] = $value;
+ $this->$key = $value;
+ }
+}
diff --git a/Library/Alidayu/SDK/request/AlibabaAliqinFcSmsNumQueryRequest.php b/Library/Alidayu/SDK/request/AlibabaAliqinFcSmsNumQueryRequest.php
new file mode 100644
index 0000000..8065bb2
--- /dev/null
+++ b/Library/Alidayu/SDK/request/AlibabaAliqinFcSmsNumQueryRequest.php
@@ -0,0 +1,115 @@
+<?php
+/**
+ * TOP API: alibaba.aliqin.fc.sms.num.query request
+ *
+ * @author auto create
+ * @since 1.0, 2016.03.01
+ */
+class AlibabaAliqinFcSmsNumQueryRequest
+{
+ /**
+ * ������������������
+ **/
+ private $bizId;
+
+ /**
+ * ������������,������
+ **/
+ private $currentPage;
+
+ /**
+ * ���������������������������������������50
+ **/
+ private $pageSize;
+
+ /**
+ * ������������������������������30������������������������yyyyMMdd
+ **/
+ private $queryDate;
+
+ /**
+ * ������������������
+ **/
+ private $recNum;
+
+ private $apiParas = array();
+
+ public function setBizId($bizId)
+ {
+ $this->bizId = $bizId;
+ $this->apiParas["biz_id"] = $bizId;
+ }
+
+ public function getBizId()
+ {
+ return $this->bizId;
+ }
+
+ public function setCurrentPage($currentPage)
+ {
+ $this->currentPage = $currentPage;
+ $this->apiParas["current_page"] = $currentPage;
+ }
+
+ public function getCurrentPage()
+ {
+ return $this->currentPage;
+ }
+
+ public function setPageSize($pageSize)
+ {
+ $this->pageSize = $pageSize;
+ $this->apiParas["page_size"] = $pageSize;
+ }
+
+ public function getPageSize()
+ {
+ return $this->pageSize;
+ }
+
+ public function setQueryDate($queryDate)
+ {
+ $this->queryDate = $queryDate;
+ $this->apiParas["query_date"] = $queryDate;
+ }
+
+ public function getQueryDate()
+ {
+ return $this->queryDate;
+ }
+
+ public function setRecNum($recNum)
+ {
+ $this->recNum = $recNum;
+ $this->apiParas["rec_num"] = $recNum;
+ }
+
+ public function getRecNum()
+ {
+ return $this->recNum;
+ }
+
+ public function getApiMethodName()
+ {
+ return "alibaba.aliqin.fc.sms.num.query";
+ }
+
+ public function getApiParas()
+ {
+ return $this->apiParas;
+ }
+
+ public function check()
+ {
+
+ RequestCheckUtil::checkNotNull($this->currentPage,"currentPage");
+ RequestCheckUtil::checkNotNull($this->pageSize,"pageSize");
+ RequestCheckUtil::checkNotNull($this->queryDate,"queryDate");
+ RequestCheckUtil::checkNotNull($this->recNum,"recNum");
+ }
+
+ public function putOtherTextParam($key, $value) {
+ $this->apiParas[$key] = $value;
+ $this->$key = $value;
+ }
+}
diff --git a/Library/Alidayu/SDK/request/AlibabaAliqinFcSmsNumSendRequest.php b/Library/Alidayu/SDK/request/AlibabaAliqinFcSmsNumSendRequest.php
new file mode 100644
index 0000000..597d5a8
--- /dev/null
+++ b/Library/Alidayu/SDK/request/AlibabaAliqinFcSmsNumSendRequest.php
@@ -0,0 +1,131 @@
+<?php
+/**
+ * TOP API: alibaba.aliqin.fc.sms.num.send request
+ *
+ * @author auto create
+ * @since 1.0, 2016.05.24
+ */
+class AlibabaAliqinFcSmsNumSendRequest
+{
+ /**
+ * ���������������������������������������������������������������������������������������������������������������������ID���������������������������������ID���������������������������������������������ID������������������������������������������
+ **/
+ private $extend;
+
+ /**
+ * ������������������������������������������������������������������������11���������������������������0���+86���������������������������������������������������������������������������������������200���������������������18600000000,13911111111,13322222222
+ **/
+ private $recNum;
+
+ /**
+ * ���������������������������������������������������������������������������-���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������
+ **/
+ private $smsFreeSignName;
+
+ /**
+ * ���������������������������������{"key":"value"}���key������������������������������������������������������������������������������������������������������������������������${code}������������������${product}���������������������������������������������������������������������{"code":"1234","product":"alidayu"}
+ **/
+ private $smsParam;
+
+ /**
+ * ������������ID���������������������������������������������������������-���������������������������������������������������SMS_585014
+ **/
+ private $smsTemplateCode;
+
+ /**
+ * ���������������������������������normal
+ **/
+ private $smsType;
+
+ private $apiParas = array();
+
+ public function setExtend($extend)
+ {
+ $this->extend = $extend;
+ $this->apiParas["extend"] = $extend;
+ }
+
+ public function getExtend()
+ {
+ return $this->extend;
+ }
+
+ public function setRecNum($recNum)
+ {
+ $this->recNum = $recNum;
+ $this->apiParas["rec_num"] = $recNum;
+ }
+
+ public function getRecNum()
+ {
+ return $this->recNum;
+ }
+
+ public function setSmsFreeSignName($smsFreeSignName)
+ {
+ $this->smsFreeSignName = $smsFreeSignName;
+ $this->apiParas["sms_free_sign_name"] = $smsFreeSignName;
+ }
+
+ public function getSmsFreeSignName()
+ {
+ return $this->smsFreeSignName;
+ }
+
+ public function setSmsParam($smsParam)
+ {
+ $this->smsParam = $smsParam;
+ $this->apiParas["sms_param"] = $smsParam;
+ }
+
+ public function getSmsParam()
+ {
+ return $this->smsParam;
+ }
+
+ public function setSmsTemplateCode($smsTemplateCode)
+ {
+ $this->smsTemplateCode = $smsTemplateCode;
+ $this->apiParas["sms_template_code"] = $smsTemplateCode;
+ }
+
+ public function getSmsTemplateCode()
+ {
+ return $this->smsTemplateCode;
+ }
+
+ public function setSmsType($smsType)
+ {
+ $this->smsType = $smsType;
+ $this->apiParas["sms_type"] = $smsType;
+ }
+
+ public function getSmsType()
+ {
+ return $this->smsType;
+ }
+
+ public function getApiMethodName()
+ {
+ return "alibaba.aliqin.fc.sms.num.send";
+ }
+
+ public function getApiParas()
+ {
+ return $this->apiParas;
+ }
+
+ public function check()
+ {
+
+ RequestCheckUtil::checkNotNull($this->recNum,"recNum");
+ RequestCheckUtil::checkNotNull($this->smsFreeSignName,"smsFreeSignName");
+ RequestCheckUtil::checkNotNull($this->smsTemplateCode,"smsTemplateCode");
+ RequestCheckUtil::checkNotNull($this->smsType,"smsType");
+ }
+
+ public function putOtherTextParam($key, $value) {
+ $this->apiParas[$key] = $value;
+ $this->$key = $value;
+ }
+}
diff --git a/Library/Alidayu/SDK/request/AlibabaAliqinFcTtsNumSinglecallRequest.php b/Library/Alidayu/SDK/request/AlibabaAliqinFcTtsNumSinglecallRequest.php
new file mode 100644
index 0000000..c1580a3
--- /dev/null
+++ b/Library/Alidayu/SDK/request/AlibabaAliqinFcTtsNumSinglecallRequest.php
@@ -0,0 +1,114 @@
+<?php
+/**
+ * TOP API: alibaba.aliqin.fc.tts.num.singlecall request
+ *
+ * @author auto create
+ * @since 1.0, 2016.05.24
+ */
+class AlibabaAliqinFcTtsNumSinglecallRequest
+{
+ /**
+ * ���������������������������������������������������,������������057188773344,13911112222,4001112222,95500
+ **/
+ private $calledNum;
+
+ /**
+ * ������������������������������������������������������������������������-������������������������������������������
+ **/
+ private $calledShowNum;
+
+ /**
+ * ���������������������������������������������������������������������������������������������������������������������ID���������������������������������ID���������������������������������������������ID������������������������������������������
+ **/
+ private $extend;
+
+ /**
+ * TTS������ID���������������������������������������������������������-������TTS���������������������������������
+ **/
+ private $ttsCode;
+
+ /**
+ * ������������������TTS������������������������������{"key"���"value"}���key���������������TTS���������������������������������������������������������������������������{"name":"xiaoming","code":"1234"}
+ **/
+ private $ttsParam;
+
+ private $apiParas = array();
+
+ public function setCalledNum($calledNum)
+ {
+ $this->calledNum = $calledNum;
+ $this->apiParas["called_num"] = $calledNum;
+ }
+
+ public function getCalledNum()
+ {
+ return $this->calledNum;
+ }
+
+ public function setCalledShowNum($calledShowNum)
+ {
+ $this->calledShowNum = $calledShowNum;
+ $this->apiParas["called_show_num"] = $calledShowNum;
+ }
+
+ public function getCalledShowNum()
+ {
+ return $this->calledShowNum;
+ }
+
+ public function setExtend($extend)
+ {
+ $this->extend = $extend;
+ $this->apiParas["extend"] = $extend;
+ }
+
+ public function getExtend()
+ {
+ return $this->extend;
+ }
+
+ public function setTtsCode($ttsCode)
+ {
+ $this->ttsCode = $ttsCode;
+ $this->apiParas["tts_code"] = $ttsCode;
+ }
+
+ public function getTtsCode()
+ {
+ return $this->ttsCode;
+ }
+
+ public function setTtsParam($ttsParam)
+ {
+ $this->ttsParam = $ttsParam;
+ $this->apiParas["tts_param"] = $ttsParam;
+ }
+
+ public function getTtsParam()
+ {
+ return $this->ttsParam;
+ }
+
+ public function getApiMethodName()
+ {
+ return "alibaba.aliqin.fc.tts.num.singlecall";
+ }
+
+ public function getApiParas()
+ {
+ return $this->apiParas;
+ }
+
+ public function check()
+ {
+
+ RequestCheckUtil::checkNotNull($this->calledNum,"calledNum");
+ RequestCheckUtil::checkNotNull($this->calledShowNum,"calledShowNum");
+ RequestCheckUtil::checkNotNull($this->ttsCode,"ttsCode");
+ }
+
+ public function putOtherTextParam($key, $value) {
+ $this->apiParas[$key] = $value;
+ $this->$key = $value;
+ }
+}
diff --git a/Library/Alidayu/SDK/request/AlibabaAliqinFcVoiceNumDoublecallRequest.php b/Library/Alidayu/SDK/request/AlibabaAliqinFcVoiceNumDoublecallRequest.php
new file mode 100644
index 0000000..ce1d3da
--- /dev/null
+++ b/Library/Alidayu/SDK/request/AlibabaAliqinFcVoiceNumDoublecallRequest.php
@@ -0,0 +1,131 @@
+<?php
+/**
+ * TOP API: alibaba.aliqin.fc.voice.num.doublecall request
+ *
+ * @author auto create
+ * @since 1.0, 2016.03.06
+ */
+class AlibabaAliqinFcVoiceNumDoublecallRequest
+{
+ /**
+ * ���������������������������������������������������,������������057188773344,13911112222,4001112222,95500
+ **/
+ private $calledNum;
+
+ /**
+ * ������������������������������������������������������������������������������������������-������������������������������������������������������������������057188773344���4001112222���95500������������������������������������������
+ **/
+ private $calledShowNum;
+
+ /**
+ * ���������������������������������������������������,������������057188773344,13911112222,4001112222,95500
+ **/
+ private $callerNum;
+
+ /**
+ * ������������������������������������������������������������������������������������������-������������������������������������������������������������������057188773344���4001112222���95500
+ **/
+ private $callerShowNum;
+
+ /**
+ * ���������������������������������������������������������������������������������������������������������������������ID���������������������������������ID���������������������������������������������ID������������������������������������������
+ **/
+ private $extend;
+
+ /**
+ * ���������������������������������������120���������������������������������������������������������������������������������������
+ **/
+ private $sessionTimeOut;
+
+ private $apiParas = array();
+
+ public function setCalledNum($calledNum)
+ {
+ $this->calledNum = $calledNum;
+ $this->apiParas["called_num"] = $calledNum;
+ }
+
+ public function getCalledNum()
+ {
+ return $this->calledNum;
+ }
+
+ public function setCalledShowNum($calledShowNum)
+ {
+ $this->calledShowNum = $calledShowNum;
+ $this->apiParas["called_show_num"] = $calledShowNum;
+ }
+
+ public function getCalledShowNum()
+ {
+ return $this->calledShowNum;
+ }
+
+ public function setCallerNum($callerNum)
+ {
+ $this->callerNum = $callerNum;
+ $this->apiParas["caller_num"] = $callerNum;
+ }
+
+ public function getCallerNum()
+ {
+ return $this->callerNum;
+ }
+
+ public function setCallerShowNum($callerShowNum)
+ {
+ $this->callerShowNum = $callerShowNum;
+ $this->apiParas["caller_show_num"] = $callerShowNum;
+ }
+
+ public function getCallerShowNum()
+ {
+ return $this->callerShowNum;
+ }
+
+ public function setExtend($extend)
+ {
+ $this->extend = $extend;
+ $this->apiParas["extend"] = $extend;
+ }
+
+ public function getExtend()
+ {
+ return $this->extend;
+ }
+
+ public function setSessionTimeOut($sessionTimeOut)
+ {
+ $this->sessionTimeOut = $sessionTimeOut;
+ $this->apiParas["session_time_out"] = $sessionTimeOut;
+ }
+
+ public function getSessionTimeOut()
+ {
+ return $this->sessionTimeOut;
+ }
+
+ public function getApiMethodName()
+ {
+ return "alibaba.aliqin.fc.voice.num.doublecall";
+ }
+
+ public function getApiParas()
+ {
+ return $this->apiParas;
+ }
+
+ public function check()
+ {
+
+ RequestCheckUtil::checkNotNull($this->calledNum,"calledNum");
+ RequestCheckUtil::checkNotNull($this->calledShowNum,"calledShowNum");
+ RequestCheckUtil::checkNotNull($this->callerNum,"callerNum");
+ RequestCheckUtil::checkNotNull($this->callerShowNum,"callerShowNum");
+ }
+
+ public function putOtherTextParam($key, $value) {
+ $this->apiParas[$key] = $value;
+ $this->$key = $value;
+ }
+}
diff --git a/Library/Alidayu/SDK/request/AlibabaAliqinFcVoiceNumSinglecallRequest.php b/Library/Alidayu/SDK/request/AlibabaAliqinFcVoiceNumSinglecallRequest.php
new file mode 100644
index 0000000..95f2581
--- /dev/null
+++ b/Library/Alidayu/SDK/request/AlibabaAliqinFcVoiceNumSinglecallRequest.php
@@ -0,0 +1,98 @@
+<?php
+/**
+ * TOP API: alibaba.aliqin.fc.voice.num.singlecall request
+ *
+ * @author auto create
+ * @since 1.0, 2016.03.01
+ */
+class AlibabaAliqinFcVoiceNumSinglecallRequest
+{
+ /**
+ * ���������������������������������������������������,������������057188773344,13911112222,4001112222,95500
+ **/
+ private $calledNum;
+
+ /**
+ * ������������������������������������������������������������������������-���������������������������������������
+ **/
+ private $calledShowNum;
+
+ /**
+ * ���������������������������������������������������������������������������������������������������������������������ID���������������������������������ID���������������������������������������������ID������������������������������������������
+ **/
+ private $extend;
+
+ /**
+ * ������������ID���������������������������������������������������������������-���������������������������������������������
+ **/
+ private $voiceCode;
+
+ private $apiParas = array();
+
+ public function setCalledNum($calledNum)
+ {
+ $this->calledNum = $calledNum;
+ $this->apiParas["called_num"] = $calledNum;
+ }
+
+ public function getCalledNum()
+ {
+ return $this->calledNum;
+ }
+
+ public function setCalledShowNum($calledShowNum)
+ {
+ $this->calledShowNum = $calledShowNum;
+ $this->apiParas["called_show_num"] = $calledShowNum;
+ }
+
+ public function getCalledShowNum()
+ {
+ return $this->calledShowNum;
+ }
+
+ public function setExtend($extend)
+ {
+ $this->extend = $extend;
+ $this->apiParas["extend"] = $extend;
+ }
+
+ public function getExtend()
+ {
+ return $this->extend;
+ }
+
+ public function setVoiceCode($voiceCode)
+ {
+ $this->voiceCode = $voiceCode;
+ $this->apiParas["voice_code"] = $voiceCode;
+ }
+
+ public function getVoiceCode()
+ {
+ return $this->voiceCode;
+ }
+
+ public function getApiMethodName()
+ {
+ return "alibaba.aliqin.fc.voice.num.singlecall";
+ }
+
+ public function getApiParas()
+ {
+ return $this->apiParas;
+ }
+
+ public function check()
+ {
+
+ RequestCheckUtil::checkNotNull($this->calledNum,"calledNum");
+ RequestCheckUtil::checkNotNull($this->calledShowNum,"calledShowNum");
+ RequestCheckUtil::checkNotNull($this->voiceCode,"voiceCode");
+ }
+
+ public function putOtherTextParam($key, $value) {
+ $this->apiParas[$key] = $value;
+ $this->$key = $value;
+ }
+}
diff --git a/Library/Alidayu/SDK/request/AppipGetRequest.php b/Library/Alidayu/SDK/request/AppipGetRequest.php
new file mode 100644
index 0000000..121fe2c
--- /dev/null
+++ b/Library/Alidayu/SDK/request/AppipGetRequest.php
@@ -0,0 +1,32 @@
+<?php
+/**
+ * TOP API: taobao.appip.get request
+ *
+ * @author auto create
+ * @since 1.0, 2014.11.26
+ */
+class AppipGetRequest
+{
+
+ private $apiParas = array();
+
+ public function getApiMethodName()
+ {
+ return "taobao.appip.get";
+ }
+
+ public function getApiParas()
+ {
+ return $this->apiParas;
+ }
+
+ public function check()
+ {
+
+ }
+
+ public function putOtherTextParam($key, $value) {
+ $this->apiParas[$key] = $value;
+ $this->$key = $value;
+ }
+}
diff --git a/Library/Alidayu/SDK/request/AreasGetRequest.php b/Library/Alidayu/SDK/request/AreasGetRequest.php
new file mode 100644
index 0000000..37f04c1
--- /dev/null
+++ b/Library/Alidayu/SDK/request/AreasGetRequest.php
@@ -0,0 +1,48 @@
+<?php
+/**
+ * TOP API: taobao.areas.get request
+ *
+ * @author auto create
+ * @since 1.0, 2016.04.13
+ */
+class AreasGetRequest
+{
+ /**
+ * ������������������������.���������:Area ������������������������;���������������������","������.���:id,type,name,parent_id,zip.
+ **/
+ private $fields;
+
+ private $apiParas = array();
+
+ public function setFields($fields)
+ {
+ $this->fields = $fields;
+ $this->apiParas["fields"] = $fields;
+ }
+
+ public function getFields()
+ {
+ return $this->fields;
+ }
+
+ public function getApiMethodName()
+ {
+ return "taobao.areas.get";
+ }
+
+ public function getApiParas()
+ {
+ return $this->apiParas;
+ }
+
+ public function check()
+ {
+
+ RequestCheckUtil::checkNotNull($this->fields,"fields");
+ }
+
+ public function putOtherTextParam($key, $value) {
+ $this->apiParas[$key] = $value;
+ $this->$key = $value;
+ }
+}
diff --git a/Library/Alidayu/SDK/request/HttpdnsGetRequest.php b/Library/Alidayu/SDK/request/HttpdnsGetRequest.php
new file mode 100644
index 0000000..786b973
--- /dev/null
+++ b/Library/Alidayu/SDK/request/HttpdnsGetRequest.php
@@ -0,0 +1,32 @@
+<?php
+/**
+ * TOP API: taobao.httpdns.get request
+ *
+ * @author auto create
+ * @since 1.0, 2016.03.24
+ */
+class HttpdnsGetRequest
+{
+
+ private $apiParas = array();
+
+ public function getApiMethodName()
+ {
+ return "taobao.httpdns.get";
+ }
+
+ public function getApiParas()
+ {
+ return $this->apiParas;
+ }
+
+ public function check()
+ {
+
+ }
+
+ public function putOtherTextParam($key, $value) {
+ $this->apiParas[$key] = $value;
+ $this->$key = $value;
+ }
+}
diff --git a/Library/Alidayu/SDK/request/KfcKeywordSearchRequest.php b/Library/Alidayu/SDK/request/KfcKeywordSearchRequest.php
new file mode 100644
index 0000000..2cf84a6
--- /dev/null
+++ b/Library/Alidayu/SDK/request/KfcKeywordSearchRequest.php
@@ -0,0 +1,85 @@
+<?php
+/**
+ * TOP API: taobao.kfc.keyword.search request
+ *
+ * @author auto create
+ * @since 1.0, 2016.03.19
+ */
+class KfcKeywordSearchRequest
+{
+ /**
+ * ������������������������������������������������������������������������������������������������������������������������������������������������taobao_auction���������������������������������������������������������������������������������������(title)���������������(content)������������������������������������������������������
+
+���������apply���������������������������������������������������������������������������������+"."+������������������������taobao_auction.title���
+
+
+������apply������������������������������������������������������������������������������������������������������������������������������������������������
+ **/
+ private $apply;
+
+ /**
+ * ���������������������������
+ **/
+ private $content;
+
+ /**
+ * ���������������������������������������������
+ **/
+ private $nick;
+
+ private $apiParas = array();
+
+ public function setApply($apply)
+ {
+ $this->apply = $apply;
+ $this->apiParas["apply"] = $apply;
+ }
+
+ public function getApply()
+ {
+ return $this->apply;
+ }
+
+ public function setContent($content)
+ {
+ $this->content = $content;
+ $this->apiParas["content"] = $content;
+ }
+
+ public function getContent()
+ {
+ return $this->content;
+ }
+
+ public function setNick($nick)
+ {
+ $this->nick = $nick;
+ $this->apiParas["nick"] = $nick;
+ }
+
+ public function getNick()
+ {
+ return $this->nick;
+ }
+
+ public function getApiMethodName()
+ {
+ return "taobao.kfc.keyword.search";
+ }
+
+ public function getApiParas()
+ {
+ return $this->apiParas;
+ }
+
+ public function check()
+ {
+
+ RequestCheckUtil::checkNotNull($this->content,"content");
+ }
+
+ public function putOtherTextParam($key, $value) {
+ $this->apiParas[$key] = $value;
+ $this->$key = $value;
+ }
+}
diff --git a/Library/Alidayu/SDK/request/TimeGetRequest.php b/Library/Alidayu/SDK/request/TimeGetRequest.php
new file mode 100644
index 0000000..15055ce
--- /dev/null
+++ b/Library/Alidayu/SDK/request/TimeGetRequest.php
@@ -0,0 +1,32 @@
+<?php
+/**
+ * TOP API: taobao.time.get request
+ *
+ * @author auto create
+ * @since 1.0, 2016.03.28
+ */
+class TimeGetRequest
+{
+
+ private $apiParas = array();
+
+ public function getApiMethodName()
+ {
+ return "taobao.time.get";
+ }
+
+ public function getApiParas()
+ {
+ return $this->apiParas;
+ }
+
+ public function check()
+ {
+
+ }
+
+ public function putOtherTextParam($key, $value) {
+ $this->apiParas[$key] = $value;
+ $this->$key = $value;
+ }
+}
diff --git a/Library/Alidayu/SDK/request/TopAuthTokenCreateRequest.php b/Library/Alidayu/SDK/request/TopAuthTokenCreateRequest.php
new file mode 100644
index 0000000..949aa83
--- /dev/null
+++ b/Library/Alidayu/SDK/request/TopAuthTokenCreateRequest.php
@@ -0,0 +1,64 @@
+<?php
+/**
+ * TOP API: taobao.top.auth.token.create request
+ *
+ * @author auto create
+ * @since 1.0, 2016.04.15
+ */
+class TopAuthTokenCreateRequest
+{
+ /**
+ * ������code���grantType==authorization_code ���������
+ **/
+ private $code;
+
+ /**
+ * ���������code���uuid������
+ **/
+ private $uuid;
+
+ private $apiParas = array();
+
+ public function setCode($code)
+ {
+ $this->code = $code;
+ $this->apiParas["code"] = $code;
+ }
+
+ public function getCode()
+ {
+ return $this->code;
+ }
+
+ public function setUuid($uuid)
+ {
+ $this->uuid = $uuid;
+ $this->apiParas["uuid"] = $uuid;
+ }
+
+ public function getUuid()
+ {
+ return $this->uuid;
+ }
+
+ public function getApiMethodName()
+ {
+ return "taobao.top.auth.token.create";
+ }
+
+ public function getApiParas()
+ {
+ return $this->apiParas;
+ }
+
+ public function check()
+ {
+
+ RequestCheckUtil::checkNotNull($this->code,"code");
+ }
+
+ public function putOtherTextParam($key, $value) {
+ $this->apiParas[$key] = $value;
+ $this->$key = $value;
+ }
+}
diff --git a/Library/Alidayu/SDK/request/TopAuthTokenRefreshRequest.php b/Library/Alidayu/SDK/request/TopAuthTokenRefreshRequest.php
new file mode 100644
index 0000000..81de734
--- /dev/null
+++ b/Library/Alidayu/SDK/request/TopAuthTokenRefreshRequest.php
@@ -0,0 +1,48 @@
+<?php
+/**
+ * TOP API: taobao.top.auth.token.refresh request
+ *
+ * @author auto create
+ * @since 1.0, 2015.08.20
+ */
+class TopAuthTokenRefreshRequest
+{
+ /**
+ * grantType==refresh_token ���������
+ **/
+ private $refreshToken;
+
+ private $apiParas = array();
+
+ public function setRefreshToken($refreshToken)
+ {
+ $this->refreshToken = $refreshToken;
+ $this->apiParas["refresh_token"] = $refreshToken;
+ }
+
+ public function getRefreshToken()
+ {
+ return $this->refreshToken;
+ }
+
+ public function getApiMethodName()
+ {
+ return "taobao.top.auth.token.refresh";
+ }
+
+ public function getApiParas()
+ {
+ return $this->apiParas;
+ }
+
+ public function check()
+ {
+
+ RequestCheckUtil::checkNotNull($this->refreshToken,"refreshToken");
+ }
+
+ public function putOtherTextParam($key, $value) {
+ $this->apiParas[$key] = $value;
+ $this->$key = $value;
+ }
+}
diff --git a/Library/Alidayu/SDK/request/TopIpoutGetRequest.php b/Library/Alidayu/SDK/request/TopIpoutGetRequest.php
new file mode 100644
index 0000000..9f91176
--- /dev/null
+++ b/Library/Alidayu/SDK/request/TopIpoutGetRequest.php
@@ -0,0 +1,32 @@
+<?php
+/**
+ * TOP API: taobao.top.ipout.get request
+ *
+ * @author auto create
+ * @since 1.0, 2015.09.07
+ */
+class TopIpoutGetRequest
+{
+
+ private $apiParas = array();
+
+ public function getApiMethodName()
+ {
+ return "taobao.top.ipout.get";
+ }
+
+ public function getApiParas()
+ {
+ return $this->apiParas;
+ }
+
+ public function check()
+ {
+
+ }
+
+ public function putOtherTextParam($key, $value) {
+ $this->apiParas[$key] = $value;
+ $this->$key = $value;
+ }
+}
diff --git a/Library/Alidayu/SDK/request/TopSecretGetRequest.php b/Library/Alidayu/SDK/request/TopSecretGetRequest.php
new file mode 100644
index 0000000..e3cd917
--- /dev/null
+++ b/Library/Alidayu/SDK/request/TopSecretGetRequest.php
@@ -0,0 +1,64 @@
+<?php
+/**
+ * TOP API: taobao.top.secret.get request
+ *
+ * @author auto create
+ * @since 1.0, 2016.04.06
+ */
+class TopSecretGetRequest
+{
+ /**
+ * ������������
+ **/
+ private $randomNum;
+
+ /**
+ * ���������������
+ **/
+ private $secretVersion;
+
+ private $apiParas = array();
+
+ public function setRandomNum($randomNum)
+ {
+ $this->randomNum = $randomNum;
+ $this->apiParas["random_num"] = $randomNum;
+ }
+
+ public function getRandomNum()
+ {
+ return $this->randomNum;
+ }
+
+ public function setSecretVersion($secretVersion)
+ {
+ $this->secretVersion = $secretVersion;
+ $this->apiParas["secret_version"] = $secretVersion;
+ }
+
+ public function getSecretVersion()
+ {
+ return $this->secretVersion;
+ }
+
+ public function getApiMethodName()
+ {
+ return "taobao.top.secret.get";
+ }
+
+ public function getApiParas()
+ {
+ return $this->apiParas;
+ }
+
+ public function check()
+ {
+
+ RequestCheckUtil::checkNotNull($this->randomNum,"randomNum");
+ }
+
+ public function putOtherTextParam($key, $value) {
+ $this->apiParas[$key] = $value;
+ $this->$key = $value;
+ }
+}
diff --git a/Library/Alidayu/SDK/request/TopatsResultGetRequest.php b/Library/Alidayu/SDK/request/TopatsResultGetRequest.php
new file mode 100644
index 0000000..eec283a
--- /dev/null
+++ b/Library/Alidayu/SDK/request/TopatsResultGetRequest.php
@@ -0,0 +1,48 @@
+<?php
+/**
+ * TOP API: taobao.topats.result.get request
+ *
+ * @author auto create
+ * @since 1.0, 2014.04.11
+ */
+class TopatsResultGetRequest
+{
+ /**
+ * ������id������������������������������task_id
+ **/
+ private $taskId;
+
+ private $apiParas = array();
+
+ public function setTaskId($taskId)
+ {
+ $this->taskId = $taskId;
+ $this->apiParas["task_id"] = $taskId;
+ }
+
+ public function getTaskId()
+ {
+ return $this->taskId;
+ }
+
+ public function getApiMethodName()
+ {
+ return "taobao.topats.result.get";
+ }
+
+ public function getApiParas()
+ {
+ return $this->apiParas;
+ }
+
+ public function check()
+ {
+
+ RequestCheckUtil::checkNotNull($this->taskId,"taskId");
+ }
+
+ public function putOtherTextParam($key, $value) {
+ $this->apiParas[$key] = $value;
+ $this->$key = $value;
+ }
+}
diff --git a/Library/Alidayu/SDK/request/TopatsTaskDeleteRequest.php b/Library/Alidayu/SDK/request/TopatsTaskDeleteRequest.php
new file mode 100644
index 0000000..0007129
--- /dev/null
+++ b/Library/Alidayu/SDK/request/TopatsTaskDeleteRequest.php
@@ -0,0 +1,48 @@
+<?php
+/**
+ * TOP API: taobao.topats.task.delete request
+ *
+ * @author auto create
+ * @since 1.0, 2014.03.27
+ */
+class TopatsTaskDeleteRequest
+{
+ /**
+ * ���������������������ID
+ **/
+ private $taskId;
+
+ private $apiParas = array();
+
+ public function setTaskId($taskId)
+ {
+ $this->taskId = $taskId;
+ $this->apiParas["task_id"] = $taskId;
+ }
+
+ public function getTaskId()
+ {
+ return $this->taskId;
+ }
+
+ public function getApiMethodName()
+ {
+ return "taobao.topats.task.delete";
+ }
+
+ public function getApiParas()
+ {
+ return $this->apiParas;
+ }
+
+ public function check()
+ {
+
+ RequestCheckUtil::checkNotNull($this->taskId,"taskId");
+ }
+
+ public function putOtherTextParam($key, $value) {
+ $this->apiParas[$key] = $value;
+ $this->$key = $value;
+ }
+}
diff --git a/Library/SMS/Config/app.php b/Library/SMS/Config/app.php
new file mode 100644
index 0000000..4a32ed3
--- /dev/null
+++ b/Library/SMS/Config/app.php
@@ -0,0 +1,21 @@
+<?php
+/**
+ * ������������������������������������������������
+ */
+
+return array(
+ /**
+ * ������������������������������
+ */
+ 'apiCommonRules' => array(//'sign' => array('name' => 'sign', 'require' => true),
+ ),
+
+ "SMSService" => array(
+ "accountSid" => "", //���������
+ "accountToken" => "", //���������Token
+ "appId" => "", //������Id
+ "serverPort" => "", //������������ ������:8883
+ "serverIP" => "" //������������������������https:// ������:sandboxapp.cloopen.com
+ )
+
+);
diff --git a/Library/SMS/Demo.php b/Library/SMS/Demo.php
new file mode 100644
index 0000000..02ecf8f
--- /dev/null
+++ b/Library/SMS/Demo.php
@@ -0,0 +1,34 @@
+<?php
+
+//���������SMS_Lite������������������������,������������������������������debug������������debug������(������false)������������������������������(���������������������������������)
+$SMS = new SMS_Lite("app.SMSService");
+
+//������������������
+$SMS->sendTemplateSMS("������������", "������������", "������Id");
+
+//������������������
+$SMS->QuerySMSTemplate("������ID");
+
+//���������������
+$SMS->voiceVerify("���������������", "������������������", "������������", "���������������������", "������������������������������������", '������������', '���������������������');
+
+//������������������
+$SMS->MediaFileUpload("���������", "���������������������");
+
+//������������ ������������������������00:00 ��� 23:59���
+$SMS->billRecords("������������", "���������������������");
+
+//IVR������
+$SMS->ivrDial("���������������", "������������", "������������");
+
+//������������
+$SMS->landingCall("������������", "������������������", "������������", "���������������������", "������������������", "������������������������������������", '������������������', '������������������', '������������', '������', '������', '���������������');
+
+//���������������������
+$SMS->queryAccountInfo();
+
+//������������������
+$SMS->QueryCallState("callid", "���������������������������url������");
+
+
+
diff --git a/Library/SMS/Lite.php b/Library/SMS/Lite.php
new file mode 100644
index 0000000..6736adb
--- /dev/null
+++ b/Library/SMS/Lite.php
@@ -0,0 +1,297 @@
+<?php
+
+/**
+ * 2016/1/8 ��������������������� @������������<wenzhenxi@vip.qq.com>
+ * ���������������������������PHPSDK������������
+ */
+class SMS_Lite {
+
+ //���������
+ private $accountSid = '';
+
+ //���������Token
+ private $accountToken = '';
+
+ //������Id
+ private $appId = '';
+
+ //REST���������
+ private $softVersion = '2013-12-26';
+
+ //������������
+ private $serverPort = '8883';
+
+ //������������������������������������������https://
+ private $serverIP = 'sandboxapp.cloopen.com';
+
+ //SDK������
+ private $SMS_SDK_REST;
+
+ //DEBUG
+ private $debug;
+
+ /**
+ * SMS_Lite ���������������������������
+ *
+ * @param $cofAddress string ������������������
+ * @param $debug bool ������������������������
+ */
+ public function __construct($cofAddress, $debug = false) {
+
+ $this->debug = $debug;
+
+ //���������������
+ $config = DI()->config->get($cofAddress);
+ //���������������������
+ if (!$config) {
+ throw new PhalApi_Exception_BadRequest(T('Config There is no'));
+ }
+ //���������������������
+ if ($this->getIndex($config, 'accountSid')) {
+ $this->accountSid = $config['accountSid'];
+ } else {
+ throw new PhalApi_Exception_BadRequest(T('accountSid There is no'));
+ }
+ //���������Token������������
+ if ($this->getIndex($config, 'accountToken')) {
+ $this->accountToken = $config['accountToken'];
+ } else {
+ throw new PhalApi_Exception_BadRequest(T('accountSid There is no'));
+ }
+ //������Id������������
+ if ($this->getIndex($config, 'appId')) {
+ $this->appId = $config['appId'];
+ } else {
+ throw new PhalApi_Exception_BadRequest(T('accountSid There is no'));
+ }
+ //������������
+ if ($this->getIndex($config, 'serverPort')) {
+ $this->serverPort = $config['serverPort'];
+ }
+ //������������
+ if ($this->getIndex($config, 'serverIP')) {
+ $this->serverIP = $config['serverIP'];
+ }
+
+ //���������SDK
+ $this->SMS_SDK_REST = new SMS_SDK_REST($this->serverIP, $this->serverPort, $this->softVersion);
+ //���������������
+ $this->SMS_SDK_REST->setAccount($this->accountSid, $this->accountToken);
+ //������������ID
+ $this->SMS_SDK_REST->setAppId($this->appId);
+ }
+
+ /**
+ * ���������������
+ *
+ * @param verifyCode ������������������������������������������������������������������������4-8���
+ * @param playTimes ���������������1���3���
+ * @param to ������������
+ * @param displayNum ���������������������
+ * @param respUrl ������������������������������������������������������������������Url������������������������������
+ * @param lang ���������������������en���������������zh������������������������zh���
+ * @param userData ���������������������
+ */
+ function voiceVerify($verifyCode, $playTimes, $to, $displayNum, $respUrl, $lang, $userData) {
+
+ //���������������������������
+ $result = $this->SMS_SDK_REST->voiceVerify($verifyCode, $playTimes, $to, $displayNum, $respUrl, $lang, $userData);
+ if ($result == NULL) {
+ throw new PhalApi_Exception_BadRequest(T("Error SMS_SDK_REST"));
+ }
+ //���������Debug���������������������������
+ if ($this->debug) {
+ $this->showarr($result);
+ }
+ return $result;
+ }
+
+ /**
+ * ������������������
+ *
+ * @param to ������������������,���������������������
+ * @param datas ������������ ��������������� ���������array('Marry','Alon')������������������������ null
+ * @param $tempId ������Id
+ */
+ function sendTemplateSMS($to, $datas, $tempId) {
+
+ // ������������������
+ $result = $this->SMS_SDK_REST->sendTemplateSMS($to, $datas, $tempId);
+ if ($result == NULL) {
+ throw new PhalApi_Exception_BadRequest(T("Error SMS_SDK_REST"));
+ }
+ //���������Debug���������������������������
+ if ($this->debug) {
+ $this->showarr($result);
+ }
+ return $result;
+ }
+
+ /**
+ * ������������������
+ *
+ * @param templateId ������ID
+ */
+ function QuerySMSTemplate($templateId) {
+
+ // ������������������������������
+ $result = $this->SMS_SDK_REST->QuerySMSTemplate($templateId);
+ if ($result == NULL) {
+ throw new PhalApi_Exception_BadRequest(T("Error SMS_SDK_REST"));
+ }
+
+ if ($this->debug) {
+ $this->showarr($result);
+ }
+ return $result;
+ }
+
+ /**
+ * ������������������
+ *
+ * @param callid ������Id
+ * @param action ���������������������������url������
+ */
+ function QueryCallState($callid, $action) {
+
+ // ������������������������������
+ $result = $this->SMS_SDK_REST->QueryCallState($callid, $action);
+ if ($result == NULL) {
+ throw new PhalApi_Exception_BadRequest(T("Error SMS_SDK_REST"));
+ }
+
+ if ($this->debug) {
+ $this->showarr($result);
+ }
+ return $result;
+ }
+
+ /**
+ * ���������������������
+ */
+ function queryAccountInfo() {
+
+ // ���������������������������������
+ $result = $this->SMS_SDK_REST->queryAccountInfo();
+ if ($result == NULL) {
+ throw new PhalApi_Exception_BadRequest(T("Error SMS_SDK_REST"));
+ }
+ if ($this->debug) {
+ $this->showarr($result);
+ }
+ return $result;
+ }
+
+ /**
+ * ������������������
+ *
+ * @param filename ���������
+ * @param path ������������������
+ */
+ function MediaFileUpload($filename, $path) {
+
+ $filePath = $path;
+ $fh = fopen($filePath, "rb");
+ $body = fread($fh, filesize($filePath));
+ fclose($fh);
+
+ // ������������������������������
+ $result = $this->SMS_SDK_REST->MediaFileUpload($filename, $body);
+ if ($result == NULL) {
+ throw new PhalApi_Exception_BadRequest(T("Error SMS_SDK_REST"));
+ }
+ if ($this->debug) {
+ $this->showarr($result);
+ }
+ return $result;
+ }
+
+ /**
+ * ������������
+ *
+ * @param to ������������
+ * @param mediaName ��������������������������� wav������mediaTxt������������������������������������mediaTxt���������������
+ * @param mediaTxt ������������
+ * @param displayNum ���������������������
+ * @param playTimes ���������������������1���3������������������1������
+ * @param respUrl ���������������������������������������������������������������Url���������������������������������
+ * @param userData ������������������
+ * @param maxCallTime ������������������
+ * @param speed ������������
+ * @param volume ������
+ * @param pitch ������
+ * @param bgsound ���������������
+ */
+ function landingCall($to, $mediaName, $mediaTxt, $displayNum, $playTimes, $respUrl, $userData, $maxCallTime, $speed, $volume, $pitch, $bgsound) {
+
+ //������������������������
+ echo "Try to make a landingcall,called is $to <br/>";
+ $result = $this->SMS_SDK_REST->landingCall($to, $mediaName, $mediaTxt, $displayNum, $playTimes, $respUrl, $userData, $maxCallTime, $speed, $volume, $pitch, $bgsound);
+ if ($result == NULL) {
+ throw new PhalApi_Exception_BadRequest(T("Error SMS_SDK_REST"));
+ }
+ if ($this->debug) {
+ $this->showarr($result);
+ }
+ return $result;
+ }
+
+ /**
+ * IVR������
+ *
+ * @param number ���������������������Dial���������������
+ * @param userdata ������������������<startservice>���������������������������������������������������Dial���������������
+ * @param record ���������������������������true���false���������������false���������������Dial���������������
+ */
+ function ivrDial($number, $userdata, $record) {
+
+ // ������IVR������������
+ $result = $this->SMS_SDK_REST->ivrDial($number, $userdata, $record);
+ if ($result == NULL) {
+ throw new PhalApi_Exception_BadRequest(T("Error SMS_SDK_REST"));
+ }
+ if ($this->debug) {
+ $this->showarr($result);
+ }
+ return $result;
+ }
+
+ /**
+ * ������������
+ *
+ * @param date day ������������������������������00:00 ��� 23:59���
+ * @param keywords ������������������������������������������������������������������������������������������������������
+ */
+ function billRecords($date, $keywords) {
+
+ // ������������������������
+ $result = $this->SMS_SDK_REST->billRecords($date, $keywords);
+ if ($result == NULL) {
+ throw new PhalApi_Exception_BadRequest(T("Error SMS_SDK_REST"));
+ }
+ if ($this->debug) {
+ $this->showarr($result);
+ }
+ return $result;
+ }
+
+ /**
+ * ������������������������ - ������������
+ */
+ public function getIndex($arr, $key, $default = '') {
+
+ return isset($arr[$key]) ? $arr[$key] : $default;
+ }
+
+ /**
+ * ������������������������
+ */
+ public function showarr($a) {
+
+ echo('<pre>');
+ print_r($a);
+ echo('</pre>');
+ }
+}
+
+
diff --git a/Library/SMS/README.md b/Library/SMS/README.md
new file mode 100644
index 0000000..7f4adb9
--- /dev/null
+++ b/Library/SMS/README.md
@@ -0,0 +1,81 @@
+#PhalApi-SMS������PhalApi������������������������������
+
+
+
+##������
+
+���������������������������������������,������������������������(���������������������������),������������������������SDK���������������Demo������������������������������������,
+���������������������������������������������������������������������������������,������������������������������������������������
+
+������:
+
+������������:[http://www.phalapi.net/](http://www.phalapi.net/ "PhalApi������")
+
+������������Git������:[http://git.oschina.net/dogstar/PhalApi/tree/release](http://git.oschina.net/dogstar/PhalApi/tree/release "������������Git������")
+
+������������������Git������:[http://git.oschina.net/dogstar/PhalApi-Library](http://git.oschina.net/dogstar/PhalApi-Library "������������Git������")
+
+
+##1. ������
+
+������������������������������������������������������������Library���������������,���������������������������������������������
+
+ //���������������������������������
+ $SMS = new SMS_Lite("app.SMSService");
+ //���������������������������������
+ $SMS = new SMS_Lite("app.SMSService",true);
+
+������������������������������������������������(���������������������������������)
+
+##2.������
+
+���������������������������app.SMSService,serverPort������serverIP������������������������������
+
+ "SMSService" => array(
+ "accountSid" => "", //���������
+ "accountToken" => "", //���������Token
+ "appId" => "", //������Id
+ "serverPort" => "", //������������ ������:8883
+ "serverIP" => "" //������������������������https:// ������:sandboxapp.cloopen.com ������������
+ )
+
+
+##3. SDK-API
+
+���������������������������������������������������������������
+
+ //������������������
+ $SMS->sendTemplateSMS("������������", "������������", "������Id");
+
+ //������������������
+ $SMS->QuerySMSTemplate("������ID");
+
+ //���������������
+ $SMS->voiceVerify("���������������", "������������������", "������������", "���������������������", "������������������������������������", '������������', '���������������������');
+
+ //������������������
+ $SMS->MediaFileUpload("���������", "���������������������");
+
+ //������������ ������������������������00:00 ��� 23:59���
+ $SMS->billRecords("������������", "���������������������");
+
+ //IVR������
+ $SMS->ivrDial("���������������", "������������", "������������");
+
+ //������������
+ $SMS->landingCall("������������", "������������������", "������������", "���������������������", "������������������", "������������������������������������", '������������������', '������������������', '������������', '������', '������', '���������������');
+
+ //���������������������
+ $SMS->queryAccountInfo();
+
+ //������������������
+ $SMS->QueryCallState("callid", "���������������������������url������");
+
+
+##4. ������
+
+������������������������������������������������������,������������������������������������������������������������������������������������������������������!
+
+���:������������������������������������������������������������������,���������������������!
+
+**������QQ���������:421032344 ���������������������!**
\ No newline at end of file
diff --git a/Library/SMS/SDK/REST.php b/Library/SMS/SDK/REST.php
new file mode 100644
index 0000000..014e030
--- /dev/null
+++ b/Library/SMS/SDK/REST.php
@@ -0,0 +1,1042 @@
+<?php
+
+/*
+ * Copyright (c) 2014 The CCP project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a Beijing Speedtong Information Technology Co.,Ltd license
+ * that can be found in the LICENSE file in the root of the web site.
+ *
+ * http://www.yuntongxun.com
+ *
+ * An additional intellectual property rights grant can be found
+ * in the file PATENTS. All contributing project authors may
+ * be found in the AUTHORS file in the root of the source tree.
+ */
+
+class SMS_SDK_REST {
+
+ private $AccountSid;
+ private $AccountToken;
+ private $AppId;
+ private $SubAccountSid;
+ private $SubAccountToken;
+ private $VoIPAccount;
+ private $VoIPPassword;
+ private $ServerIP;
+ private $ServerPort;
+ private $SoftVersion;
+ private $Batch; //������sh
+ private $BodyType = "xml";//���������������������������json ���xml
+ private $enabeLog = true; //���������������������������true���
+ private $Filename = "../log.txt"; //������������
+ private $Handle;
+
+ function __construct($ServerIP, $ServerPort, $SoftVersion) {
+
+ $this->Batch = date("YmdHis");
+ $this->ServerIP = $ServerIP;
+ $this->ServerPort = $ServerPort;
+ $this->SoftVersion = $SoftVersion;
+ $this->Handle = fopen($this->Filename, 'a');
+ }
+
+ /**
+ * ���������������
+ *
+ * @param AccountSid ���������
+ * @param AccountToken ���������Token
+ */
+ function setAccount($AccountSid, $AccountToken) {
+
+ $this->AccountSid = $AccountSid;
+ $this->AccountToken = $AccountToken;
+ }
+
+ /**
+ * ���������������
+ *
+ * @param SubAccountSid ���������
+ * @param SubAccountToken ���������Token
+ * @param VoIPAccount VoIP������
+ * @param VoIPPassword VoIP������
+ */
+ function setSubAccount($SubAccountSid, $SubAccountToken, $VoIPAccount, $VoIPPassword) {
+
+ $this->SubAccountSid = $SubAccountSid;
+ $this->SubAccountToken = $SubAccountToken;
+ $this->VoIPAccount = $VoIPAccount;
+ $this->VoIPPassword = $VoIPPassword;
+ }
+
+ /**
+ * ������������ID
+ *
+ * @param AppId ������ID
+ */
+ function setAppId($AppId) {
+
+ $this->AppId = $AppId;
+ }
+
+ /**
+ * ������������
+ *
+ * @param log ������������
+ */
+ function showlog($log) {
+
+ if ($this->enabeLog) {
+ fwrite($this->Handle, $log . "\n");
+ }
+ }
+
+ /**
+ * ������HTTPS������
+ */
+ function curl_post($url, $data, $header, $post = 1) {
+
+ //���������curl
+ $ch = curl_init();
+ //������������
+ $res = curl_setopt($ch, CURLOPT_URL, $url);
+ curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
+ curl_setopt($ch, CURLOPT_HEADER, 0);
+ curl_setopt($ch, CURLOPT_POST, $post);
+ if ($post) {
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
+ }
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
+ curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
+ $result = curl_exec($ch);
+ //������������
+ if ($result == FALSE) {
+ if ($this->BodyType == 'json') {
+ $result = "{\"statusCode\":\"172001\",\"statusMsg\":\"������������\"}";
+ } else {
+ $result = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><Response><statusCode>172001</statusCode><statusMsg>������������</statusMsg></Response>";
+ }
+ }
+
+ curl_close($ch);
+ return $result;
+ }
+
+ /**
+ * ���������������
+ *
+ * @param friendlyName ���������������
+ */
+ function createSubAccount($friendlyName) {
+
+ //������������������������������������������������������������
+ $auth = $this->accAuth();
+ if ($auth != "") {
+ return $auth;
+ }
+ // ������������������
+ if ($this->BodyType == "json") {
+ $body = "{'appId':'$this->AppId','friendlyName':'$friendlyName'}";
+ } else {
+ $body = "<SubAccount>
+ <appId>$this->AppId</appId>
+ <friendlyName>$friendlyName</friendlyName>
+ </SubAccount>";
+ }
+ $this->showlog("request body = " . $body);
+ // ���������sig������
+ $sig = strtoupper(md5($this->AccountSid . $this->AccountToken . $this->Batch));
+ // ������������URL
+ $url = "https://$this->ServerIP:$this->ServerPort/$this->SoftVersion/Accounts/$this->AccountSid/SubAccounts?sig=$sig";
+ $this->showlog("request url = " . $url);
+ // ������������������������Id + ������������ + ���������
+ $authen = base64_encode($this->AccountSid . ":" . $this->Batch);
+ // ������������
+ $header = array(
+ "Accept:application/$this->BodyType",
+ "Content-Type:application/$this->BodyType;charset=utf-8",
+ "Authorization:$authen"
+ );
+ // ���������
+ $result = $this->curl_post($url, $body, $header);
+ $this->showlog("response body = " . $result);
+ if ($this->BodyType == "json") {//JSON������
+ $datas = json_decode($result);
+ } else { //xml������
+ $datas = simplexml_load_string(trim($result, " \t\n\r"));
+ }
+ // if($datas == FALSE){
+ // $datas = new stdClass();
+ // $datas->statusCode = '172003';
+ // $datas->statusMsg = '������������������';
+ // }
+ return $datas;
+ }
+
+ /**
+ * ���������������
+ *
+ * @param startNo ���������������������������0������
+ * @param offset ���������������������������������������1���������������100���
+ */
+ function getSubAccounts($startNo, $offset) {
+
+ //������������������������������������������������������������
+ $auth = $this->accAuth();
+ if ($auth != "") {
+ return $auth;
+ }
+ // ������������������
+ $body = "
+ <SubAccount>
+ <appId>$this->AppId</appId>
+ <startNo>$startNo</startNo>
+ <offset>$offset</offset>
+ </SubAccount>";
+ if ($this->BodyType == "json") {
+ $body = "{'appId':'$this->AppId','startNo':'$startNo','offset':'$offset'}";
+ } else {
+ $body = "
+ <SubAccount>
+ <appId>$this->AppId</appId>
+ <startNo>$startNo</startNo>
+ <offset>$offset</offset>
+ </SubAccount>";
+ }
+ $this->showlog("request body = " . $body);
+ // ���������sig������
+ $sig = strtoupper(md5($this->AccountSid . $this->AccountToken . $this->Batch));
+ // ������������URL
+ $url = "https://$this->ServerIP:$this->ServerPort/$this->SoftVersion/Accounts/$this->AccountSid/GetSubAccounts?sig=$sig";
+ $this->showlog("request url = " . $url);
+ // ������������������������Id + ������������ + ������������
+ $authen = base64_encode($this->AccountSid . ":" . $this->Batch);
+ // ������������
+ $header = array(
+ "Accept:application/$this->BodyType",
+ "Content-Type:application/$this->BodyType;charset=utf-8",
+ "Authorization:$authen"
+ );
+ // ������������
+ $result = $this->curl_post($url, $body, $header);
+ $this->showlog("response body = " . $result);
+ if ($this->BodyType == "json") {//JSON������
+ $datas = json_decode($result);
+ } else { //xml������
+ $datas = simplexml_load_string(trim($result, " \t\n\r"));
+ }
+ // if($datas == FALSE){
+ // $datas = new stdClass();
+ // $datas->statusCode = '172003';
+ // $datas->statusMsg = '������������������';
+ // }
+ return $datas;
+ }
+
+ /**
+ * ���������������������
+ *
+ * @param friendlyName ���������������
+ */
+ function querySubAccount($friendlyName) {
+
+ //������������������������������������������������������������
+ $auth = $this->accAuth();
+ if ($auth != "") {
+ return $auth;
+ }
+ // ������������������
+
+ if ($this->BodyType == "json") {
+ $body = "{'appId':'$this->AppId','friendlyName':'$friendlyName'}";
+ } else {
+ $body = "
+ <SubAccount>
+ <appId>$this->AppId</appId>
+ <friendlyName>$friendlyName</friendlyName>
+ </SubAccount>";
+ }
+ $this->showlog("request body = " . $body);
+ // ���������sig������
+ $sig = strtoupper(md5($this->AccountSid . $this->AccountToken . $this->Batch));
+ // ������������URL
+ $url = "https://$this->ServerIP:$this->ServerPort/$this->SoftVersion/Accounts/$this->AccountSid/QuerySubAccountByName?sig=$sig";
+ $this->showlog("request url = " . $url);
+ // ������������������������Id + ������������ + ������������
+ $authen = base64_encode($this->AccountSid . ":" . $this->Batch);
+ // ������������
+ $header = array(
+ "Accept:application/$this->BodyType",
+ "Content-Type:application/$this->BodyType;charset=utf-8",
+ "Authorization:$authen"
+ );
+ // ������������
+ $result = $this->curl_post($url, $body, $header);
+ $this->showlog("response body = " . $result);
+ if ($this->BodyType == "json") {//JSON������
+ $datas = json_decode($result);
+ } else { //xml������
+ $datas = simplexml_load_string(trim($result, " \t\n\r"));
+ }
+ // if($datas == FALSE){
+ // $datas = new stdClass();
+ // $datas->statusCode = '172003';
+ // $datas->statusMsg = '������������������';
+ // }
+ return $datas;
+ }
+
+ /**
+ * ������������������
+ *
+ * @param to ���������������������������������,���������������������
+ * @param datas ������������
+ * @param $tempId ������Id
+ */
+ function sendTemplateSMS($to, $datas, $tempId) {
+
+ //������������������������������������������������������������
+ $auth = $this->accAuth();
+ if ($auth != "") {
+ return $auth;
+ }
+ // ������������������
+ if ($this->BodyType == "json") {
+ $data = "";
+ for ($i = 0; $i < count($datas); $i++) {
+ $data = $data . "'" . $datas[$i] . "',";
+ }
+ $body = "{'to':'$to','templateId':'$tempId','appId':'$this->AppId','datas':[" . $data . "]}";
+ } else {
+ $data = "";
+ for ($i = 0; $i < count($datas); $i++) {
+ $data = $data . "<data>" . $datas[$i] . "</data>";
+ }
+ $body = "<TemplateSMS>
+ <to>$to</to>
+ <appId>$this->AppId</appId>
+ <templateId>$tempId</templateId>
+ <datas>" . $data . "</datas>
+ </TemplateSMS>";
+ }
+ $this->showlog("request body = " . $body);
+ // ���������sig������
+ $sig = strtoupper(md5($this->AccountSid . $this->AccountToken . $this->Batch));
+ // ������������URL
+ $url = "https://$this->ServerIP:$this->ServerPort/$this->SoftVersion/Accounts/$this->AccountSid/SMS/TemplateSMS?sig=$sig";
+ $this->showlog("request url = " . $url);
+ // ������������������������Id + ������������ + ������������
+ $authen = base64_encode($this->AccountSid . ":" . $this->Batch);
+ // ������������
+ $header = array(
+ "Accept:application/$this->BodyType",
+ "Content-Type:application/$this->BodyType;charset=utf-8",
+ "Authorization:$authen"
+ );
+ // ������������
+ $result = $this->curl_post($url, $body, $header);
+ $this->showlog("response body = " . $result);
+ if ($this->BodyType == "json") {//JSON������
+ $datas = json_decode($result);
+ } else { //xml������
+ $datas = simplexml_load_string(trim($result, " \t\n\r"));
+ }
+ // if($datas == FALSE){
+ // $datas = new stdClass();
+ // $datas->statusCode = '172003';
+ // $datas->statusMsg = '������������������';
+ // }
+ //������������������
+ if ($datas->statusCode == 0) {
+ if ($this->BodyType == "json") {
+ $datas->TemplateSMS = $datas->templateSMS;
+ unset($datas->templateSMS);
+ }
+ }
+
+ return $datas;
+ }
+
+ /**
+ * ������������
+ *
+ * @param from ������������������
+ * @param to ������������������
+ * @param customerSerNum ������������������������������
+ * @param fromSerNum ������������������������
+ * @param promptTone ������������������������
+ * @param userData ���������������������
+ * @param maxCallTime ������������������
+ * @param hangupCdrUrl ������������������������
+ * @param alwaysPlay ���������������������������
+ * @param terminalDtmf ������������������promptTone������������������������
+ * @param needBothCdr ������������������������������
+ * @param needRecord ������������
+ * @param countDownTime ���������������������
+ * @param countDownPrompt ���������������������������������������
+ */
+ function callBack($from, $to, $customerSerNum, $fromSerNum, $promptTone, $alwaysPlay, $terminalDtmf, $userData, $maxCallTime, $hangupCdrUrl, $needBothCdr, $needRecord, $countDownTime, $countDownPrompt) {
+
+ //������������������������������������������������������������
+ $auth = $this->subAuth();
+ if ($auth != "") {
+ return $auth;
+ }
+ // ������������������
+ if ($this->BodyType == "json") {
+ $body = "{'from':'$from','to':'$to','customerSerNum':'$customerSerNum','fromSerNum':'$fromSerNum','promptTone':'$promptTone','userData':'$userData','maxCallTime':'$maxCallTime','hangupCdrUrl':'$hangupCdrUrl',
+ 'alwaysPlay':'$alwaysPlay','terminalDtmf':'$terminalDtmf','needBothCdr':'$needBothCdr',
+ 'needRecord':'$needRecord','countDownTime':'$$countDownTime','countDownPrompt':'$countDownPrompt'}";
+ } else {
+ $body = "<CallBack>
+ <from>$from</from>
+ <to>$to</to>
+ <customerSerNum>$customerSerNum</customerSerNum>
+ <fromSerNum>$fromSerNum</fromSerNum>
+ <promptTone>$promptTone</promptTone>
+ <userData>$userData</userData>
+ <maxCallTime>$maxCallTime</maxCallTime>
+ <hangupCdrUrl>$hangupCdrUrl</hangupCdrUrl>
+ <alwaysPlay>$alwaysPlay</alwaysPlay>
+ <terminalDtmf>$terminalDtmf</terminalDtmf>
+ <needBothCdr>$needBothCdr</needBothCdr>
+ <needRecord>$needRecord</needRecord>
+ <countDownTime>$countDownTime</countDownTime>
+ <countDownPrompt>$countDownPrompt</countDownPrompt>
+ </CallBack>";
+ }
+ $this->showlog("request body = " . $body);
+ // ���������sig������
+ $sig = strtoupper(md5($this->SubAccountSid . $this->SubAccountToken . $this->Batch));
+ // ������������URL
+ $url = "https://$this->ServerIP:$this->ServerPort/$this->SoftVersion/SubAccounts/$this->SubAccountSid/Calls/Callback?sig=$sig";
+ $this->showlog("request url = " . $url);
+ // ������������������������Id + ������������ + ���������
+ $authen = base64_encode($this->SubAccountSid . ":" . $this->Batch);
+ // ������������
+ $header = array(
+ "Accept:application/$this->BodyType",
+ "Content-Type:application/$this->BodyType;charset=utf-8",
+ "Authorization:$authen"
+ );
+ // ���������
+ $result = $this->curl_post($url, $body, $header);
+ $this->showlog("response body = " . $result);
+ if ($this->BodyType == "json") {//JSON������
+ $datas = json_decode($result);
+ } else { //xml������
+ $datas = simplexml_load_string(trim($result, " \t\n\r"));
+ }
+ // if($datas == FALSE){
+ // $datas = new stdClass();
+ // $datas->statusCode = '172003';
+ // $datas->statusMsg = '������������������';
+ // }
+ return $datas;
+ }
+
+ /**
+ * ������������
+ *
+ * @param to ������������
+ * @param mediaName ��������������������������� wav������mediaTxt������������������������������������mediaTxt���������������
+ * @param mediaTxt ������������
+ * @param displayNum ���������������������
+ * @param playTimes ���������������������1���3������������������1������
+ * @param respUrl ���������������������������������������������������������������Url���������������������������������
+ * @param userData ������������������
+ * @param maxCallTime ������������������
+ * @param speed ������������
+ * @param volume ������
+ * @param pitch ������
+ * @param bgsound ���������������
+ */
+ function landingCall($to, $mediaName, $mediaTxt, $displayNum, $playTimes, $respUrl, $userData, $maxCallTime, $speed, $volume, $pitch, $bgsound) {
+
+ //������������������������������������������������������������
+ $auth = $this->accAuth();
+ if ($auth != "") {
+ return $auth;
+ }
+ // ������������������
+ if ($this->BodyType == "json") {
+ $body = "{'playTimes':'$playTimes','mediaTxt':'$mediaTxt','mediaName':'$mediaName','to':'$to','appId':'$this->AppId','displayNum':'$displayNum','respUrl':'$respUrl',
+ 'userData':'$userData','maxCallTime':'$maxCallTime','speed':'$speed','volume':'$volume','pitch':'$pitch','bgsound':'$bgsound'}";
+ } else {
+ $body = "<LandingCall>
+ <to>$to</to>
+ <mediaName>$mediaName</mediaName>
+ <mediaTxt>$mediaTxt</mediaTxt>
+ <appId>$this->AppId</appId>
+ <displayNum>$displayNum</displayNum>
+ <playTimes>$playTimes</playTimes>
+ <respUrl>$respUrl</respUrl>
+ <userData>$userData</userData>
+ <maxCallTime>$maxCallTime</maxCallTime>
+ <speed>$speed</speed>
+ <volume>$volume</volume>
+ <pitch>$pitch</pitch>
+ <bgsound>$bgsound</bgsound>
+ </LandingCall>";
+ }
+ $this->showlog("request body = " . $body);
+ // ���������sig������
+ $sig = strtoupper(md5($this->AccountSid . $this->AccountToken . $this->Batch));
+ // ������������URL
+ $url = "https://$this->ServerIP:$this->ServerPort/$this->SoftVersion/Accounts/$this->AccountSid/Calls/LandingCalls?sig=$sig";
+ $this->showlog("request url = " . $url);
+ // ������������������������Id + ������������ + ������������
+ $authen = base64_encode($this->AccountSid . ":" . $this->Batch);
+ // ������������
+ $header = array(
+ "Accept:application/$this->BodyType",
+ "Content-Type:application/$this->BodyType;charset=utf-8",
+ "Authorization:$authen"
+ );
+ // ������������
+ $result = $this->curl_post($url, $body, $header);
+ $this->showlog("response body = " . $result);
+ if ($this->BodyType == "json") {//JSON������
+ $datas = json_decode($result);
+ } else { //xml������
+ $datas = simplexml_load_string(trim($result, " \t\n\r"));
+ }
+ // if($datas == FALSE){
+ // $datas = new stdClass();
+ // $datas->statusCode = '172003';
+ // $datas->statusMsg = '������������������';
+ // }
+ return $datas;
+ }
+
+ /**
+ * ���������������
+ *
+ * @param verifyCode ������������������������������������������������������������������������4-8���
+ * @param playTimes ���������������1���3���
+ * @param to ������������
+ * @param displayNum ���������������������
+ * @param respUrl ������������������������������������������������������������������Url������������������������������
+ * @param lang ������������
+ * @param userData ���������������������
+ */
+ function voiceVerify($verifyCode, $playTimes, $to, $displayNum, $respUrl, $lang, $userData) {
+
+ //������������������������������������������������������������
+ $auth = $this->accAuth();
+ if ($auth != "") {
+ return $auth;
+ }
+ // ������������������
+ if ($this->BodyType == "json") {
+ $body = "{'appId':'$this->AppId','verifyCode':'$verifyCode','playTimes':'$playTimes','to':'$to','respUrl':'$respUrl','displayNum':'$displayNum',
+ 'lang':'$lang','userData':'$userData'}";
+ } else {
+ $body = "<VoiceVerify>
+ <appId>$this->AppId</appId>
+ <verifyCode>$verifyCode</verifyCode>
+ <playTimes>$playTimes</playTimes>
+ <to>$to</to>
+ <respUrl>$respUrl</respUrl>
+ <displayNum>$displayNum</displayNum>
+ <lang>$lang</lang>
+ <userData>$userData</userData>
+ </VoiceVerify>";
+ }
+ $this->showlog("request body = " . $body);
+ // ���������sig������
+ $sig = strtoupper(md5($this->AccountSid . $this->AccountToken . $this->Batch));
+ // ������������URL
+ $url = "https://$this->ServerIP:$this->ServerPort/$this->SoftVersion/Accounts/$this->AccountSid/Calls/VoiceVerify?sig=$sig";
+ $this->showlog("request url = " . $url);
+ // ������������������������Id + ������������ + ������������
+ $authen = base64_encode($this->AccountSid . ":" . $this->Batch);
+ // ������������
+ $header = array(
+ "Accept:application/$this->BodyType",
+ "Content-Type:application/$this->BodyType;charset=utf-8",
+ "Authorization:$authen"
+ );
+ // ������������
+ $result = $this->curl_post($url, $body, $header);
+ $this->showlog("response body = " . $result);
+ if ($this->BodyType == "json") {//JSON������
+ $datas = json_decode($result);
+ } else { //xml������
+ $datas = simplexml_load_string(trim($result, " \t\n\r"));
+ }
+ // if($datas == FALSE){
+ // $datas = new stdClass();
+ // $datas->statusCode = '172003';
+ // $datas->statusMsg = '������������������';
+ // }
+ return $datas;
+ }
+
+ /**
+ * IVR������
+ *
+ * @param number ���������������������Dial���������������
+ * @param userdata ������������������<startservice>���������������������������������������������������Dial���������������
+ * @param record ���������������������������true���false���������������false���������������Dial���������������
+ */
+ function ivrDial($number, $userdata, $record) {
+
+ //������������������������������������������������������������
+ $auth = $this->accAuth();
+ if ($auth != "") {
+ return $auth;
+ }
+ // ������������������
+ $body = " <Request>
+ <Appid>$this->AppId</Appid>
+ <Dial number='$number' userdata='$userdata' record='$record'></Dial>
+ </Request>";
+ $this->showlog("request body = " . $body);
+ // ���������sig������
+ $sig = strtoupper(md5($this->AccountSid . $this->AccountToken . $this->Batch));
+ // ������������URL
+ $url = "https://$this->ServerIP:$this->ServerPort/$this->SoftVersion/Accounts/$this->AccountSid/ivr/dial?sig=$sig";
+ $this->showlog("request url = " . $url);
+ // ������������������������Id + ������������ + ������������
+ $authen = base64_encode($this->AccountSid . ":" . $this->Batch);
+ // ������������
+ $header = array(
+ "Accept:application/xml",
+ "Content-Type:application/xml;charset=utf-8",
+ "Authorization:$authen"
+ );
+ // ������������
+ $result = $this->curl_post($url, $body, $header);
+ $this->showlog("response body = " . $result);
+ $datas = simplexml_load_string(trim($result, " \t\n\r"));
+ // if($datas == FALSE){
+ // $datas = new stdClass();
+ // $datas->statusCode = '172003';
+ // $datas->statusMsg = '������������������';
+ // }
+ return $datas;
+ }
+
+ /**
+ * ������������
+ *
+ * @param date day ������������������������������00:00 ��� 23:59���
+ * @param keywords ������������������������������������������������������������������������������������������������������
+ */
+ function billRecords($date, $keywords) {
+
+ //������������������������������������������������������������
+ $auth = $this->accAuth();
+ if ($auth != "") {
+ return $auth;
+ }
+ // ������������������
+ if ($this->BodyType == "json") {
+ $body = "{'appId':'$this->AppId','date':'$date','keywords':'$keywords'}";
+ } else {
+ $body = "<BillRecords>
+ <appId>$this->AppId</appId>
+ <date>$date</date>
+ <keywords>$keywords</keywords>
+ </BillRecords>";
+ }
+ $this->showlog("request body = " . $body);
+ // ���������sig������
+ $sig = strtoupper(md5($this->AccountSid . $this->AccountToken . $this->Batch));
+ // ������������URL
+ $url = "https://$this->ServerIP:$this->ServerPort/$this->SoftVersion/Accounts/$this->AccountSid/BillRecords?sig=$sig";
+ $this->showlog("request url = " . $url);
+ // ������������������������Id + ������������ + ������������
+ $authen = base64_encode($this->AccountSid . ":" . $this->Batch);
+ // ������������
+ $header = array(
+ "Accept:application/$this->BodyType",
+ "Content-Type:application/$this->BodyType;charset=utf-8",
+ "Authorization:$authen"
+ );
+ // ������������
+ $result = $this->curl_post($url, $body, $header);
+ $this->showlog("response body = " . $result);
+ if ($this->BodyType == "json") {//JSON������
+ $datas = json_decode($result);
+ } else { //xml������
+ $datas = simplexml_load_string(trim($result, " \t\n\r"));
+ }
+ // if($datas == FALSE){
+ // $datas = new stdClass();
+ // $datas->statusCode = '172003';
+ // $datas->statusMsg = '������������������';
+ // }
+ return $datas;
+ }
+
+ /**
+ * ���������������������
+ */
+ function queryAccountInfo() {
+
+ //������������������������������������������������������������
+ $auth = $this->accAuth();
+ if ($auth != "") {
+ return $auth;
+ }
+ // ���������sig������
+ $sig = strtoupper(md5($this->AccountSid . $this->AccountToken . $this->Batch));
+ // ������������URL
+ $url = "https://$this->ServerIP:$this->ServerPort/$this->SoftVersion/Accounts/$this->AccountSid/AccountInfo?sig=$sig";
+ $this->showlog("request url = " . $url);
+ // ������������������������Id + ������������ + ������������
+ $authen = base64_encode($this->AccountSid . ":" . $this->Batch);
+ // ������������
+ $header = array(
+ "Accept:application/$this->BodyType",
+ "Content-Type:application/$this->BodyType;charset=utf-8",
+ "Authorization:$authen"
+ );
+ // ������������
+ $result = $this->curl_post($url, "", $header, 0);
+ $this->showlog("response body = " . $result);
+ if ($this->BodyType == "json") {//JSON������
+ $datas = json_decode($result);
+ } else { //xml������
+ $datas = simplexml_load_string(trim($result, " \t\n\r"));
+ }
+ // if($datas == FALSE){
+ // $datas = new stdClass();
+ // $datas->statusCode = '172003';
+ // $datas->statusMsg = '������������������';
+ // }
+ return $datas;
+ }
+
+ /**
+ * ������������������
+ *
+ * @param date templateId ������ID
+ */
+ function QuerySMSTemplate($templateId) {
+
+ //������������������������������������������������������������
+ $auth = $this->accAuth();
+ if ($auth != "") {
+ return $auth;
+ }
+ // ������������������
+ if ($this->BodyType == "json") {
+ $body = "{'appId':'$this->AppId','templateId':'$templateId'}";
+ } else {
+ $body = "<Request>
+ <appId>$this->AppId</appId>
+ <templateId>$templateId</templateId>
+ </Request>";
+ }
+ $this->showlog("request body = " . $body);
+ // ���������sig������
+ $sig = strtoupper(md5($this->AccountSid . $this->AccountToken . $this->Batch));
+ // ������������URL
+ $url = "https://$this->ServerIP:$this->ServerPort/$this->SoftVersion/Accounts/$this->AccountSid/SMS/QuerySMSTemplate?sig=$sig";
+ $this->showlog("request url = " . $url);
+ // ������������������������Id + ������������ + ������������
+ $authen = base64_encode($this->AccountSid . ":" . $this->Batch);
+ // ������������
+ $header = array(
+ "Accept:application/$this->BodyType",
+ "Content-Type:application/$this->BodyType;charset=utf-8",
+ "Authorization:$authen"
+ );
+ // ������������
+ $result = $this->curl_post($url, $body, $header);
+ $this->showlog("response body = " . $result);
+ if ($this->BodyType == "json") {//JSON������
+ $datas = json_decode($result);
+ } else { //xml������
+ $datas = simplexml_load_string(trim($result, " \t\n\r"));
+ }
+ // if($datas == FALSE){
+ // $datas = new stdClass();
+ // $datas->statusCode = '172003';
+ // $datas->statusMsg = '������������������';
+ // }
+ return $datas;
+ }
+
+ /**
+ * ������������
+ *
+ * @param callSid ���������32���������������������������������������
+ * @param type 0��� ������������������������������������1 ������������������������������������������������������������������������2��� ���������������������������������������������������������������������������������0���
+ */
+ function CallCancel($callSid, $type) {
+
+ //������������������������������������������������������������
+ $auth = $this->subAuth();
+ if ($auth != "") {
+ return $auth;
+ }
+ // ������������������
+ if ($this->BodyType == "json") {
+ $body = "{'appId':'$this->AppId','callSid':'$callSid','type':'$type'}";
+ } else {
+ $body = "<CallCancel>
+ <appId>$this->AppId</appId>
+ <callSid>$callSid</callSid>
+ <type>$type</type>
+ </CallCancel>";
+ }
+ $this->showlog("request body = " . $body);
+ // ���������sig������
+ $sig = strtoupper(md5($this->SubAccountSid . $this->SubAccountToken . $this->Batch));
+ // ������������URL
+ $url = "https://$this->ServerIP:$this->ServerPort/$this->SoftVersion/SubAccounts/$this->SubAccountSid/Calls/CallCancel?sig=$sig";
+ $this->showlog("request url = " . $url);
+ // ������������������������Id + ������������ + ������������
+ $authen = base64_encode($this->SubAccountSid . ":" . $this->Batch);
+ // ������������
+ $header = array(
+ "Accept:application/$this->BodyType",
+ "Content-Type:application/$this->BodyType;charset=utf-8",
+ "Authorization:$authen"
+ );
+ // ������������
+ $result = $this->curl_post($url, $body, $header);
+ $this->showlog("response body = " . $result);
+ if ($this->BodyType == "json") {//JSON������
+ $datas = json_decode($result);
+ } else { //xml������
+ $datas = simplexml_load_string(trim($result, " \t\n\r"));
+ }
+ // if($datas == FALSE){
+ // $datas = new stdClass();
+ // $datas->statusCode = '172003';
+ // $datas->statusMsg = '������������������';
+ // }
+ return $datas;
+ }
+
+ /**
+ * ������������������
+ *
+ * @param callid ������Id
+ * @param action ���������������������������url������
+ */
+ function QueryCallState($callid, $action) {
+
+ //������������������������������������������������������������
+ $auth = $this->accAuth();
+ if ($auth != "") {
+ return $auth;
+ }
+ // ������������������
+ if ($this->BodyType == "json") {
+ $body = "{'Appid':'$this->AppId','QueryCallState':{'callid':'$callid','action':'$action'}}";
+ } else {
+ $body = "<Request>
+ <Appid>$this->AppId</Appid>
+ <QueryCallState callid ='$callid' action='$action'/>
+ </Request>";
+ }
+ $this->showlog("request body = " . $body);
+ // ���������sig������
+ $sig = strtoupper(md5($this->AccountSid . $this->AccountToken . $this->Batch));
+ // ������������URL
+ $url = "https://$this->ServerIP:$this->ServerPort/$this->SoftVersion/Accounts/$this->AccountSid/ivr/call?sig=$sig&callid=$callid";
+ $this->showlog("request url = " . $url);
+ // ������������������������Id + ������������ + ������������
+ $authen = base64_encode($this->AccountSid . ":" . $this->Batch);
+ // ������������
+ $header = array(
+ "Accept:application/$this->BodyType",
+ "Content-Type:application/$this->BodyType;charset=utf-8",
+ "Authorization:$authen"
+ );
+ // ������������
+ $result = $this->curl_post($url, $body, $header);
+ $this->showlog("response body = " . $result);
+ if ($this->BodyType == "json") {//JSON������
+ $datas = json_decode($result);
+ } else { //xml������
+ $datas = simplexml_load_string(trim($result, " \t\n\r"));
+ }
+ // if($datas == FALSE){
+ // $datas = new stdClass();
+ // $datas->statusCode = '172003';
+ // $datas->statusMsg = '������������������';
+ // }
+ return $datas;
+ }
+
+ /**
+ * ������������������
+ *
+ * @param callSid ������Id
+ */
+ function CallResult($callSid) {
+
+ //������������������������������������������������������������
+ $auth = $this->accAuth();
+ if ($auth != "") {
+ return $auth;
+ }
+ // ���������sig������
+ $sig = strtoupper(md5($this->AccountSid . $this->AccountToken . $this->Batch));
+ // ������������URL
+ $url = "https://$this->ServerIP:$this->ServerPort/$this->SoftVersion/Accounts/$this->AccountSid/CallResult?sig=$sig&callsid=$callSid";
+ $this->showlog("request url = " . $url);
+ // ������������������������Id + ������������ + ������������
+ $authen = base64_encode($this->AccountSid . ":" . $this->Batch);
+ // ������������
+ $header = array(
+ "Accept:application/$this->BodyType",
+ "Content-Type:application/$this->BodyType;charset=utf-8",
+ "Authorization:$authen"
+ );
+ // ������������
+ $result = $this->curl_post($url, "", $header, 0);
+ $this->showlog("response body = " . $result);
+ if ($this->BodyType == "json") {//JSON������
+ $datas = json_decode($result);
+ } else { //xml������
+ $datas = simplexml_load_string(trim($result, " \t\n\r"));
+ }
+ // if($datas == FALSE){
+ // $datas = new stdClass();
+ // $datas->statusCode = '172003';
+ // $datas->statusMsg = '������������������';
+ // }
+ return $datas;
+ }
+
+ /**
+ * ������������������
+ *
+ * @param filename ���������
+ * @param body ������������
+ */
+ function MediaFileUpload($filename, $body) {
+
+ //������������������������������������������������������������
+ $auth = $this->accAuth();
+ if ($auth != "") {
+ return $auth;
+ }
+ // ������������������
+
+ $this->showlog("request body = " . $body);
+ // ���������sig������
+ $sig = strtoupper(md5($this->AccountSid . $this->AccountToken . $this->Batch));
+ // ������������URL
+ $url = "https://$this->ServerIP:$this->ServerPort/$this->SoftVersion/Accounts/$this->AccountSid/Calls/MediaFileUpload?sig=$sig&appid=$this->AppId&filename=$filename";
+ $this->showlog("request url = " . $url);
+ // ������������������������Id + ������������ + ������������
+ $authen = base64_encode($this->AccountSid . ":" . $this->Batch);
+ // ������������
+ $header = array(
+ "Accept:application/$this->BodyType",
+ "Content-Type:application/octet-stream",
+ "Authorization:$authen"
+ );
+ // ������������
+ $result = $this->curl_post($url, $body, $header);
+ $this->showlog("response body = " . $result);
+ if ($this->BodyType == "json") {//JSON������
+ $datas = json_decode($result);
+ } else { //xml������
+ $datas = simplexml_load_string(trim($result, " \t\n\r"));
+ }
+ // if($datas == FALSE){
+ // $datas = new stdClass();
+ // $datas->statusCode = '172003';
+ // $datas->statusMsg = '������������������';
+ // }
+ return $datas;
+ }
+
+ /**
+ * ���������������
+ */
+ function subAuth() {
+
+ if ($this->ServerIP == "") {
+ $data = new stdClass();
+ $data->statusCode = '172004';
+ $data->statusMsg = 'IP������';
+ return $data;
+ }
+ if ($this->ServerPort <= 0) {
+ $data = new stdClass();
+ $data->statusCode = '172005';
+ $data->statusMsg = '���������������������������0���';
+ return $data;
+ }
+ if ($this->SoftVersion == "") {
+ $data = new stdClass();
+ $data->statusCode = '172013';
+ $data->statusMsg = '���������������';
+ return $data;
+ }
+ if ($this->SubAccountSid == "") {
+ $data = new stdClass();
+ $data->statusCode = '172008';
+ $data->statusMsg = '���������������';
+ return $data;
+ }
+ if ($this->SubAccountToken == "") {
+ $data = new stdClass();
+ $data->statusCode = '172009';
+ $data->statusMsg = '���������������������';
+ return $data;
+ }
+ if ($this->AppId == "") {
+ $data = new stdClass();
+ $data->statusCode = '172012';
+ $data->statusMsg = '������ID������';
+ return $data;
+ }
+ }
+
+ /**
+ * ���������������
+ */
+ function accAuth() {
+
+ if ($this->ServerIP == "") {
+ $data = new stdClass();
+ $data->statusCode = '172004';
+ $data->statusMsg = 'IP������';
+ return $data;
+ }
+ if ($this->ServerPort <= 0) {
+ $data = new stdClass();
+ $data->statusCode = '172005';
+ $data->statusMsg = '���������������������������0���';
+ return $data;
+ }
+ if ($this->SoftVersion == "") {
+ $data = new stdClass();
+ $data->statusCode = '172013';
+ $data->statusMsg = '���������������';
+ return $data;
+ }
+ if ($this->AccountSid == "") {
+ $data = new stdClass();
+ $data->statusCode = '172006';
+ $data->statusMsg = '���������������';
+ return $data;
+ }
+ if ($this->AccountToken == "") {
+ $data = new stdClass();
+ $data->statusCode = '172007';
+ $data->statusMsg = '���������������������';
+ return $data;
+ }
+ if ($this->AppId == "") {
+ $data = new stdClass();
+ $data->statusCode = '172012';
+ $data->statusMsg = '������ID������';
+ return $data;
+ }
+ }
+}
+
+?>
diff --git a/PhalApi/PhalApi/Helper/api_desc_tpl.php b/PhalApi/PhalApi/Helper/api_desc_tpl.php
index a6a57fe..aca6097 100644
--- a/PhalApi/PhalApi/Helper/api_desc_tpl.php
+++ b/PhalApi/PhalApi/Helper/api_desc_tpl.php
@@ -208,12 +208,12 @@
/**
* ������
*/
-$version = PHALAPI_VERSION;
+$version = '���������';
echo <<<EOT
<div class="ui blue message">
<strong>���������������</strong> ������������������������������������������������������������ ?service= ������������������������������/������
</div>
- <p>© Powered By <a href="http://www.phalapi.net/" target="_blank">PhalApi {$version}</a><span id="version_update"></span></p>
+ <p>© Powered By {$version}<span id="version_update"></span></p>
</div>
</div>
<script type="text/javascript">
@@ -251,28 +251,6 @@
checkLastestVersion();
})
- // ������������������
- function checkLastestVersion() {
- $.ajax({
- url:'https://www.phalapi.net/check_lastest_version.php',
- type:'get',
- data:{version : '$version'},
- success:function(res,status,xhr){
- if (!res.ret || res.ret != 200) {
- return;
- }
- if (res.data.need_upgrade >= 0) {
- return;
- }
-
- $('#version_update').html(' | <a target="_blank" href=" ' + res.data.url + ' "><strong>��������������� PhalApi ' + res.data.version + '</strong></a>');
- },
- error:function(error){
- console.log(error)
- }
- })
-
- }
</script>
</body>
</html>
diff --git a/Public/listAllApis.php b/Public/listAllApis.php
new file mode 100644
index 0000000..8374822
--- /dev/null
+++ b/Public/listAllApis.php
@@ -0,0 +1,53 @@
+<?php
+/**
+ * PhalApi������������������������ - ������������
+ *
+ * - ���Api_������������������������������
+ * - ���service������������������
+ * - ������������������������
+ *
+ * <br>���������������<br>
+ * ```
+ * <?php
+ * // ������������������
+ * class Api_Demo extends PhalApi_Api {
+ * /**
+ * * ������������������
+ * * @desc ������������
+ * * /
+ * public function index() {
+ * }
+ * }
+ * ```
+ * @license http://www.phalapi.net/license GPL ������
+ * @link http://www.phalapi.net/
+ * @author xiaoxunzhao 2015-10-25
+ * @modify Aevit 2014-10-29
+ * @modify shwy 2017-03-02
+ * @modify dogstar 2017-06-17
+ */
+
+require_once dirname(__FILE__) . '/../init.php';
+
+$projectName = 'PhalApi������������������';
+
+/**
+ * ���������������������
+ * TODO: ���������������������������������������������
+ */
+$apiDirName = 'Demo';
+
+/**
+ * ������������
+ * TODO: ���������������������������������������������������������./Api������������������
+ */
+$libraryPaths = array(
+ 'Library/User/User', // User������
+ 'Library/Auth/Auth', // Auth������
+ 'Library/Qiniu/CDN', // ������������
+ 'Library/WechatMini/WechatMini', // ���������������������
+);
+
+$apiList = new PhalApi_Helper_ApiList($projectName);
+$apiList->render($apiDirName, $libraryPaths);
+
diff --git a/Public/yfs/checkApiParams.php b/Public/yfs/checkApiParams.php
new file mode 100644
index 0000000..1ceff0c
--- /dev/null
+++ b/Public/yfs/checkApiParams.php
@@ -0,0 +1,34 @@
+<?php
+/**
+ * ������ - ������������������������
+ */
+
+require_once dirname(__FILE__) . '/../init.php';
+
+$projectName = 'PhalApi������������������';
+
+/**
+ * TODO: ������������������
+ */
+DI()->loader->addDirs('Yfs');
+
+/**
+ * ������������
+ *
+ * TODO: ���������������������������������������������������������./Api������������������
+ */
+$libraryPaths = array(
+ 'Library/User/User', // User������
+ 'Library/Auth/Auth', // Auth������
+ 'Library/Qiniu/CDN', // ������������
+ 'Library/WechatMini/WechatMini', // ���������������������
+);
+
+foreach ($libraryPaths as $aPath) {
+ $toAddDir = str_replace('/', DIRECTORY_SEPARATOR, $aPath);
+ DI()->loader->addDirs($toAddDir);
+}
+
+$apiDesc = new PhalApi_Helper_ApiDesc($projectName);
+$apiDesc->render();
+
diff --git a/Public/yfs/listAllApis.php b/Public/yfs/listAllApis.php
new file mode 100644
index 0000000..5084bf9
--- /dev/null
+++ b/Public/yfs/listAllApis.php
@@ -0,0 +1,53 @@
+<?php
+/**
+ * PhalApi������������������������ - ������������
+ *
+ * - ���Api_������������������������������
+ * - ���service������������������
+ * - ������������������������
+ *
+ * <br>���������������<br>
+ * ```
+ * <?php
+ * // ������������������
+ * class Api_Demo extends PhalApi_Api {
+ * /**
+ * * ������������������
+ * * @desc ������������
+ * * /
+ * public function index() {
+ * }
+ * }
+ * ```
+ * @license http://www.phalapi.net/license GPL ������
+ * @link http://www.phalapi.net/
+ * @author xiaoxunzhao 2015-10-25
+ * @modify Aevit 2014-10-29
+ * @modify shwy 2017-03-02
+ * @modify dogstar 2017-06-17
+ */
+
+require_once dirname(__FILE__) . '/../init.php';
+
+$projectName = 'PhalApi������������������';
+
+/**
+ * ���������������������
+ * TODO: ���������������������������������������������
+ */
+$apiDirName = 'Yfs';
+
+/**
+ * ������������
+ * TODO: ���������������������������������������������������������./Api������������������
+ */
+$libraryPaths = array(
+ 'Library/User/User', // User������
+ 'Library/Auth/Auth', // Auth������
+ 'Library/Qiniu/CDN', // ������������
+ 'Library/WechatMini/WechatMini', // ���������������������
+);
+
+$apiList = new PhalApi_Helper_ApiList($projectName);
+$apiList->render($apiDirName, $libraryPaths);
+
diff --git a/Yfs/Api/Send.php b/Yfs/Api/Send.php
index 02f66e3..8f0caaf 100644
--- a/Yfs/Api/Send.php
+++ b/Yfs/Api/Send.php
@@ -5,4 +5,65 @@
class Api_Send extends PhalApi_Api {
+ public $alidayu;
+
+ public function __construct(){
+ $this->alidayu = Alidayu_Lite::getInstance();
+ }
+
+ /**
+ * ������������
+ * @return [type] [description]
+ */
+ public function getRules(){
+ return array(
+ 'register_sms' => array(
+ 'phone' => array(
+ 'name' => 'phone',
+ 'type' => 'string',
+ 'require' => true,
+ 'desc' => '���������������'
+ )
+ )
+ );
+ }
+
+
+ /**
+ * ������������
+ * @desc ������������������
+ * @return bool code ������������0��������������� 1������������
+ * @return string msg ������������
+ */
+ public function register_sms(){
+ $rs = array('code' => 0, 'msg' => '');
+ $sms_service = new Domain_SmsCode();
+ $scene = 'register';
+ if($sms_service->check($this->phone, $scene)){
+ $code = Common_Util::random(6, 1);
+ $send_json_data = json_encode(array('mobile_validate' => $code));
+ if($this->alidayu->send($this->phone, $send_json_data, $scene)){
+ $data = array();
+ $time = time();
+ $data['phone'] = $this->phone;
+ $data['code'] = $code;
+ $data['create_time'] = date('Y-m-d H:i:s', $time);
+ $data['expire_time'] = date('Y-m-d H:i:s', $time + 60);
+ $data['scene'] = $scene;
+ $data['status'] = 0;
+ $sms_service->add($data);
+ $rs['msg'] = '������������';
+ }
+ else{
+ $rs['code'] = 1;
+ $rs['msg'] = '������������';
+ }
+ }
+ else{
+ $rs['code'] = 1;
+ $rs['msg'] = '������������������������,������������60���';
+ }
+
+ return $rs;
+ }
}
\ No newline at end of file
diff --git a/Yfs/Api/User.php b/Yfs/Api/User.php
index aa9054b..07af236 100644
--- a/Yfs/Api/User.php
+++ b/Yfs/Api/User.php
@@ -10,38 +10,61 @@
'register' => array(
'phone' => array('name' => 'phone', 'type' => 'string', 'require' => true, 'desc' => '������������'),
'password' => array('name' => 'password', 'type' => 'string', 'require' => true, 'desc' => '������'),
+ 'code' => array('name' => 'code', 'type' => 'string', 'require' => true, 'desc' => '���������������'),
),
- 'getBaseInfo' => array(
- 'userId' => array('name' => 'user_id', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '������ID'),
+ 'login' => array(
+ 'phone' => array('name' => 'phone', 'type' => 'string', 'require' => true, 'desc' => '������������'),
+ 'password' => array('name' => 'password', 'type' => 'string', 'require' => true, 'desc' => '������'),
),
- 'getMultiBaseInfo' => array(
- 'userIds' => array('name' => 'user_ids', 'type' => 'array', 'format' => 'explode', 'require' => true, 'desc' => '������ID������������������������'),
+ 'getUserInfo' => array(
+ 'phone' => array('name' => 'phone', 'type' => 'string', 'require' => true, 'desc' => '������������'),
),
);
}
-
+ /**
+ * ������������
+ * @desc ������������������
+ * @return bool code ������������0��������������������� 1������������
+ * @return string msg ������������
+ */
public function register(){
- $rs = array('code' => 0, 'msg' => '', 'info' => array());
- $userService = new Domain_User();
- if($userService->checkPhone($this->phone)){
- $data['phone'] = $this->phone;
- $data['encrypt'] = Common_Util::random(8);
- $data['password'] = md5(md5($this->password).$data['encrypt']);
- $data['nickname'] = $this->phone;
- $data['refresh'] = 5;
- $data['is_open_upload'] = 1;
- $data['video'] = 1;
- $data['create_time'] = date('Y-m-d H:i:s');
- $data['edit_time'] = $data['create_time'];
- $data['is_lock'] = 0;
- $data['role'] = '596f23ab9e74bb85388b4567';
- if($userService->register($data)){
- $rs['msg'] = '������������������';
+ $rs = array('code' => 0, 'msg' => '');
+ $user_service = new Domain_User();
+ if($user_service->checkPhone($this->phone)){
+ $sms_service = new Domain_SmsCode();
+ $result = $sms_service->checkSmsCode($this->phone, $this->code, 'register');
+ if($result == 0){
+ $data['phone'] = $this->phone;
+ $data['encrypt'] = Common_Util::random(8);
+ $data['password'] = md5(md5($this->password).$data['encrypt']);
+ $data['nickname'] = $this->phone;
+ $data['refresh'] = 5;
+ $data['is_open_upload'] = 1;
+ $data['video'] = 1;
+ $data['create_time'] = date('Y-m-d H:i:s');
+ $data['edit_time'] = $data['create_time'];
+ $data['is_lock'] = 0;
+ $data['role'] = '596f23ab9e74bb85388b4567';
+ if($user_service->register($data)){
+ $rs['msg'] = '������������������';
+ }
+ else{
+ $rs['code'] = 1;
+ $rs['msg'] = '������������';
+ }
+ }
+ elseif($result == 1){
+ $rs['code'] = 1;
+ $rs['msg'] = '������������������������������������������������������������������������';
+ }
+ elseif($result == 2){
+ $rs['code'] = 1;
+ $rs['msg'] = '���������������������';
}
else{
$rs['code'] = 1;
- $rs['msg'] = '������������';
+ $rs['msg'] = '������������������,������������������������';
}
}
else{
@@ -52,64 +75,62 @@
}
/**
+ * ������������
+ * @desc ������������������������
+ * @return bool code ������������0��������������������� 1������������������
+ * @return string msg ������������
+ */
+ public function login(){
+ $rs = array('code' => 0, 'msg' => '');
+ $user_service = new Domain_User();
+ if(!$user_service->checkPhone($this->phone) && $user_service->checkUserStatus($this->phone)){
+ if($user_service->login($this->phone, $this->password)){
+ $rs['msg'] = '������������������';
+ }
+ else{
+ $rs['code'] = 1;
+ $rs['msg'] = '������������������������������������';
+ }
+ }
+ else{
+ $rs['code'] = 1;
+ $rs['msg'] = '������������������������������������';
+ }
+ return $rs;
+ }
+
+ /**
* ������������������
- * @return [type] [description]
+ * @desc ������������������������
+ * @return bool code ������������0��������������� 1������������
+ * @return string msg ������������
+ * @return object info ������������������
+ * @return string info._id ������id
+ * @return string info.phone ������������
+ * @return string info.encypt ���������
+ * @return string info.password ������
+ * @return string info.nickname ������������
+ * @return string info.refresh_frequency ������������
+ * @return string info.is_open_upload ������������������
+ * @return string info.is_lock ������������������0������������������1������������
*/
public function getUserInfo(){
+ $rs = array('code' => 0, 'msg' => '', 'info' => array());
- }
+ $user_service = new Domain_User();
+ $user = $user_service->getUserInfoByPhone($this->phone);
- /**
- * ������������������������
- * @desc ������������������������������������
- * @return int code ������������0��������������� 1���������������������
- * @return object info ������������������
- * @return int info.id ������ID
- * @return string info.name ������������
- * @return string info.note ������������
- * @return string msg ������������
- */
- public function getBaseInfo() {
- $rs = array('code' => 0, 'msg' => '', 'info' => array());
-
- $domain = new Domain_User();
- $info = $domain->getBaseInfo($this->userId);
-
- if (empty($info)) {
- DI()->logger->debug('user not found', $this->userId);
-
+ if ($user) {
+ $rs['code'] = 0;
+ $rs['msg'] = '������������������������';
+ $rs['info'] = $info;
+ }
+ else{
$rs['code'] = 1;
- $rs['msg'] = T('user not exists');
- return $rs;
- }
-
- $rs['info'] = $info;
-
- return $rs;
- }
-
- /**
- * ������������������������������
- * @desc ������������������������������������
- * @return int code ������������0������������
- * @return array list ������������
- * @return int list[].id ������ID
- * @return string list[].name ������������
- * @return string list[].note ������������
- * @return string msg ������������
- * @exception 400 ������������������
- * @exception 500 ���������������������
- */
- public function getMultiBaseInfo() {
- $rs = array('code' => 0, 'msg' => '', 'list' => array());
-
- $domain = new Domain_User();
- foreach ($this->userIds as $userId) {
- $rs['list'][] = $domain->getBaseInfo($userId);
-
- DI()->tracer->mark('FINISH_GET_INFO');
+ $rs['msg'] = '���������������������';
}
return $rs;
}
+
}
diff --git a/Yfs/Domain/SmsCode.php b/Yfs/Domain/SmsCode.php
new file mode 100644
index 0000000..2500933
--- /dev/null
+++ b/Yfs/Domain/SmsCode.php
@@ -0,0 +1,65 @@
+<?php
+
+class Domain_SmsCode {
+
+ public function __construct(){
+ $this->model = new Model_SmsCode();
+ }
+
+ public function add($smsInfo) {
+ return $this->model->add($smsInfo);
+ }
+
+ /**
+ * ������������������������������������
+ * @param [type] $phone [description]
+ * @param [type] $scene [description]
+ * @return [type] [description]
+ */
+ public function check($phone, $scene = ""){
+ if(!empty($scene)){
+ $sms = $this->model->getPhoneLastSms(array('phone' => $phone, 'scene' => $scene))[0];
+ if($sms){
+ return strtotime($sms['create_time']) + 60 < time()?true:false;
+ }
+ return true;
+ }
+ else{
+ return false;
+ }
+ }
+
+ /**
+ * ���������������������
+ * @param [type] $phone [description]
+ * @param [type] $code [description]
+ * @param [type] $scene [description]
+ * @return [type] [description]
+ */
+ public function checkSmsCode($phone, $code, $scene){
+ if(!empty($phone) && !empty($code) && !empty($scene)){
+ $sms = $this->model->getPhoneLastSms(array('phone' => $phone, 'scene' => $scene))[0];
+ if($sms){
+ if($sms['status'] == 0 && strtotime($sms['expire_time']) >= time()){
+ if($sms['code'] == $code){
+ $this->model->update(array('status' => 1), array('_id' => $sms['_id']));
+ return 0;
+ }
+ else{
+ return 2;
+ }
+ }
+ else{
+ return 1;
+ }
+ }
+ else{
+ return 3;
+ }
+ }
+ else{
+ return 3;
+ }
+ }
+
+}
diff --git a/Yfs/Domain/User.php b/Yfs/Domain/User.php
index cd27f68..b682d32 100644
--- a/Yfs/Domain/User.php
+++ b/Yfs/Domain/User.php
@@ -1,18 +1,73 @@
<?php
-
+/**
+ * ���������������
+ */
class Domain_User {
public function __construct(){
$this->model = new Model_User();
}
+ /**
+ * ������
+ * @param [type] $regUserInfo [description]
+ * @return [type] [description]
+ */
public function register($regUserInfo) {
return $this->model->register($regUserInfo);
}
+ /**
+ * ������������
+ * @param [type] $phone [description]
+ * @return [type] [description]
+ */
public function checkPhone($phone){
- $user = $this->model->get(array('phone' => $phone));
+ $user = $this->getUserInfoByPhone($phone);
return $user?false:true;
}
+ /**
+ * ������������������������
+ * @param [type] $phone [description]
+ * @return [type] [description]
+ */
+ public function checkUserStatus($phone){
+ $user = $this->getUserInfoByPhone($phone);
+ if($user && $user['is_lock'] == 0){
+ return true;
+ }
+ else{
+ return false;
+ }
+ }
+
+ /**
+ * ���������������������������������
+ * @param [type] $phone [description]
+ * @return [type] [description]
+ */
+ public function getUserInfoByPhone($phone){
+ return $this->model->get(array('phone' => $phone));
+ }
+
+ /**
+ * ������������
+ * @return [type] [description]
+ */
+ public function login($phone, $password){
+ $user = $this->getUserInfoByPhone($phone);
+ if($user){
+ if(md5(md5($password).$user['encrypt']) == $user['password']){
+ return true;
+ }
+ else{
+ return false;
+ }
+ }
+ else{
+ return false;
+ }
+ }
+
}
diff --git a/Yfs/Model/SmsCode.php b/Yfs/Model/SmsCode.php
new file mode 100644
index 0000000..c514834
--- /dev/null
+++ b/Yfs/Model/SmsCode.php
@@ -0,0 +1,19 @@
+<?php
+
+class Model_SmsCode extends Model_Base{
+
+ public $table = 'sms_code';
+
+ /**
+ * ������������������������������������
+ * @param [type] $phone [description]
+ * @param [type] $scene [description]
+ * @return [type] [description]
+ */
+ public function getPhoneLastSms($query = array()){
+ return $this->getList($query, array(), array('_id' => -1), 1);
+ }
+
+
+
+}
--
Gitblit v1.8.0