From 212e70d8d24c8b6e45236416760c12f6d31b190b Mon Sep 17 00:00:00 2001 From: zhaoxiang <756958008@qq.com> Date: Fri, 21 Apr 2017 00:19:49 +0800 Subject: [PATCH 1/2] =?UTF-8?q?modified=20=E5=AE=8C=E6=88=90=E9=98=BF?= =?UTF-8?q?=E9=87=8C=E5=A4=A7=E4=BA=8E=E6=8E=A5=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ApiStore/ApiSDK/TaoBao/AuthSign.class.php | 7 +- .../ApiStore/ApiSDK/TaoBao/Http.class.php | 25 ++++++ .../Home/ApiStore/ApiSDK/TaoBaoSDK.class.php | 76 ++----------------- Application/Home/ApiStore/DayuSms.class.php | 39 ++++++++++ 4 files changed, 72 insertions(+), 75 deletions(-) create mode 100644 Application/Home/ApiStore/DayuSms.class.php diff --git a/Application/Home/ApiStore/ApiSDK/TaoBao/AuthSign.class.php b/Application/Home/ApiStore/ApiSDK/TaoBao/AuthSign.class.php index 2ba971c..6360925 100644 --- a/Application/Home/ApiStore/ApiSDK/TaoBao/AuthSign.class.php +++ b/Application/Home/ApiStore/ApiSDK/TaoBao/AuthSign.class.php @@ -10,21 +10,20 @@ class AuthSign { /** * 获取身份秘钥 * @param array $params - * @param object $appInfo + * @param array $appInfo * @author zhaoxiang * @return string */ public static function getSign($params, $appInfo) { ksort($params); - $stringToBeSigned = $appInfo->secretKey; + $stringToBeSigned = $appInfo['secretKey']; foreach ($params as $k => $v) { if (is_string($v) && "@" != substr($v, 0, 1)) { $stringToBeSigned .= "$k$v"; } } - unset($k, $v); - $stringToBeSigned .= $appInfo->secretKey; + $stringToBeSigned .= $appInfo['secretKey']; return strtoupper(md5($stringToBeSigned)); } diff --git a/Application/Home/ApiStore/ApiSDK/TaoBao/Http.class.php b/Application/Home/ApiStore/ApiSDK/TaoBao/Http.class.php index b439eaa..81b6c17 100644 --- a/Application/Home/ApiStore/ApiSDK/TaoBao/Http.class.php +++ b/Application/Home/ApiStore/ApiSDK/TaoBao/Http.class.php @@ -8,6 +8,31 @@ namespace Home\ApiStore\ApiSDK\TaoBao; +use Home\ORG\Response; + class Http { + public static function get($url) { + $ch = curl_init(); + curl_setopt($ch, CURLOPT_URL, $url); + curl_setopt($ch, CURLOPT_FAILONERROR, false); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + curl_setopt($ch, CURLOPT_USERAGENT, "top-sdk-php"); + + if (strlen($url) > 5 && strtolower(substr($url, 0, 5)) == "https") { + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); + curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); + } + $response = curl_exec($ch); + + if (curl_errno($ch)) { + Response::error(curl_error($ch)); + } else { + Response::error($response); + } + curl_close($ch); + + return $response; + } + } \ No newline at end of file diff --git a/Application/Home/ApiStore/ApiSDK/TaoBaoSDK.class.php b/Application/Home/ApiStore/ApiSDK/TaoBaoSDK.class.php index 7451e14..1cda8f7 100644 --- a/Application/Home/ApiStore/ApiSDK/TaoBaoSDK.class.php +++ b/Application/Home/ApiStore/ApiSDK/TaoBaoSDK.class.php @@ -22,12 +22,13 @@ class TaoBaoSDK { private $sysParams; private $apiParams; - private $queryStr; + + public $url; /** * TaoBaoSDK constructor. - * @param object $appInfo 应用信息 - * @param string $method 接口名称 + * @param array $appInfo 应用信息 + * @param string $method 接口名称 * @param string $session */ public function __construct($appInfo, $method, $session = null) { @@ -61,76 +62,9 @@ class TaoBaoSDK { public function buildUrl() { $allParams = array_merge($this->sysParams, $this->apiParams); $allParams['sign'] = AuthSign::getSign($allParams, $this->appInfo); - $encodeParams = array_map('urlencode', $allParams); - $this->queryStr = http_build_query($encodeParams); + $this->url = $this->appInfo['url'].'?'.http_build_query($allParams); return $this; } - 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 { - $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)); - } - } - $response = 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($response, $httpStatusCode); - } - } - curl_close($ch); - - return $response; - } - } \ No newline at end of file diff --git a/Application/Home/ApiStore/DayuSms.class.php b/Application/Home/ApiStore/DayuSms.class.php new file mode 100644 index 0000000..2307cb7 --- /dev/null +++ b/Application/Home/ApiStore/DayuSms.class.php @@ -0,0 +1,39 @@ + + */ + +namespace Home\ApiStore; + + +use Home\ApiStore\ApiSDK\TaoBao\Http; +use Home\ApiStore\ApiSDK\TaoBaoSDK; + +class DayuSms { + + private $appInfo = array( + 'secretKey' => '880ad9f6daae467f2ec2e11f50932f8f', + 'appKey' => '23762660', + 'url' => 'http://gw.api.taobao.com/router/rest' + ); + + private $apiRule = array( + 'sms_type' => 'normal', + 'sms_free_sign_name' => '', + 'rec_num' => '', + 'sms_template_code' => '' + ); + + public function send(){ + $sdk = new TaoBaoSDK($this->appInfo, 'alibaba.aliqin.fc.sms.num.send'); + $sdk->buildSysParams(); + $sdk->buildApiParams(array( + 'sms_free_sign_name' => 'Api管理后台', + 'rec_num' => '17366005512', + 'sms_template_code' => 'SMS_62650093' + ), $this->apiRule); + $sdk->buildUrl(); + return Http::get($sdk->url); + } +} \ No newline at end of file From d6e555d38db314fa220a7b99b493e635dcdf8ddc Mon Sep 17 00:00:00 2001 From: zhaoxiang <756958008@qq.com> Date: Sat, 22 Apr 2017 20:09:57 +0800 Subject: [PATCH 2/2] =?UTF-8?q?modified=20=E7=BB=86=E8=8A=82=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Application/Admin/View/Log/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Application/Admin/View/Log/index.html b/Application/Admin/View/Log/index.html index 452a7f5..05496ae 100644 --- a/Application/Admin/View/Log/index.html +++ b/Application/Admin/View/Log/index.html @@ -136,7 +136,7 @@ returnStr += '查看'; returnStr += '删除'; + 'data-id="' + row.id +'" data-info="你确定删除当前日志么?" data-url="{:U(\'del\')}">删除'; return returnStr; } }