mirror of
https://gitee.com/apiadmin/ApiAdmin.git
synced 2025-04-06 03:58:00 +08:00
Merge remote-tracking branch 'origin/apiadmin-v2.0' into apiadmin-v2.0
This commit is contained in:
commit
f45c95897c
@ -136,7 +136,7 @@
|
||||
returnStr += '<span class="layui-btn edit layui-btn-normal" ' +
|
||||
'data-id="' + row.id +'" data-url="{:U(\'showDetail\')}">查看</span>';
|
||||
returnStr += '<span class="layui-btn layui-btn-danger confirm" ' +
|
||||
'data-id="' + row.id +'" data-info="你确定删除当前菜单么?" data-url="{:U(\'del\')}">删除</span>';
|
||||
'data-id="' + row.id +'" data-info="你确定删除当前日志么?" data-url="{:U(\'del\')}">删除</span>';
|
||||
return returnStr;
|
||||
}
|
||||
}
|
||||
|
@ -10,21 +10,20 @@ class AuthSign {
|
||||
/**
|
||||
* 获取身份秘钥
|
||||
* @param array $params
|
||||
* @param object $appInfo
|
||||
* @param array $appInfo
|
||||
* @author zhaoxiang <zhaoxiang051405@gmail.com>
|
||||
* @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));
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
39
Application/Home/ApiStore/DayuSms.class.php
Normal file
39
Application/Home/ApiStore/DayuSms.class.php
Normal file
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
/**
|
||||
* @since 2017-04-20
|
||||
* @author zhaoxiang <zhaoxiang051405@gmail.com>
|
||||
*/
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user