From fe44cb1d41326489b6e0f1144c159def43b840ab Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Tue, 10 Oct 2023 14:54:50 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E9=87=87=E9=9B=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/service/TopClient.php | 385 ++++++++++ app/controller/api/Auth.php | 214 ++++-- .../merchant/store/product/Product.php | 1 + extend/taobao/ApplicationVar.php | 47 ++ extend/taobao/Autoloader.php | 78 +++ extend/taobao/ClusterTopClient.php | 199 ++++++ extend/taobao/HttpdnsGetRequest.php | 23 + extend/taobao/LtInflector.php | 18 + extend/taobao/QimenCloud/QimenCloudClient.php | 384 ++++++++++ extend/taobao/RequestCheckUtil.php | 111 +++ extend/taobao/ResultSet.php | 22 + extend/taobao/SpiUtils.php | 221 ++++++ extend/taobao/TopLogger.php | 45 ++ extend/taobao/TopSdk.php | 40 ++ extend/taobao/__MACOSX/._Autoloader.php | Bin 0 -> 176 bytes extend/taobao/__MACOSX/._TopSdk.php | Bin 0 -> 176 bytes .../QimenCloud/._QimenCloudClient.php | Bin 0 -> 176 bytes extend/taobao/__MACOSX/top/._.DS_Store | Bin 0 -> 120 bytes .../taobao/__MACOSX/top/._ApplicationVar.php | Bin 0 -> 176 bytes extend/taobao/__MACOSX/top/._SpiUtils.php | Bin 0 -> 176 bytes extend/taobao/__MACOSX/top/._TopClient.php | Bin 0 -> 176 bytes extend/taobao/__MACOSX/top/._fileTest.php | Bin 0 -> 176 bytes extend/taobao/aliyun/AliyunClient.php | 255 +++++++ extend/taobao/dingtalk/DingTalkClient.php | 656 ++++++++++++++++++ extend/taobao/dingtalk/DingTalkConstant.php | 18 + extend/taobao/domain/Area.php | 35 + extend/taobao/domain/BybtInfoDTO.php | 50 ++ extend/taobao/domain/Data.php | 15 + extend/taobao/domain/FavoritesDetail.php | 20 + extend/taobao/domain/FavoritesInfo.php | 20 + extend/taobao/domain/Feature.php | 20 + extend/taobao/domain/Item.php | 560 +++++++++++++++ extend/taobao/domain/ItemImg.php | 30 + extend/taobao/domain/KfcSearchResult.php | 29 + extend/taobao/domain/Location.php | 40 ++ extend/taobao/domain/MaifanPromotionDTO.php | 30 + extend/taobao/domain/MapData.php | 75 ++ extend/taobao/domain/NTbkItem.php | 220 ++++++ extend/taobao/domain/OAuthOtherInfo.php | 45 ++ extend/taobao/domain/OpenAccount.php | 170 +++++ extend/taobao/domain/OpenAccountResult.php | 30 + .../taobao/domain/OpenAccountSearchResult.php | 30 + .../domain/OpenAccountTokenApplyResult.php | 30 + .../domain/OpenAccountTokenValidateResult.php | 30 + extend/taobao/domain/OpenaccountLong.php | 30 + extend/taobao/domain/OpenaccountObject.php | 30 + extend/taobao/domain/OpenaccountVoid.php | 25 + extend/taobao/domain/OrderData.php | 30 + extend/taobao/domain/Product.php | 137 ++++ extend/taobao/domain/ProductImg.php | 40 ++ extend/taobao/domain/ProductPropImg.php | 46 ++ extend/taobao/domain/PromotionExtend.php | 25 + extend/taobao/domain/PromotionList.php | 30 + extend/taobao/domain/PropImg.php | 35 + extend/taobao/domain/PropValue.php | 60 ++ extend/taobao/domain/RecommendItemList.php | 20 + extend/taobao/domain/Results.php | 15 + extend/taobao/domain/Sku.php | 120 ++++ extend/taobao/domain/SpCampaign.php | 40 ++ extend/taobao/domain/TokenInfo.php | 40 ++ extend/taobao/domain/TokenInfoExt.php | 20 + extend/taobao/domain/TopDownloadRecordDo.php | 25 + extend/taobao/domain/TopNInfoDTO.php | 35 + extend/taobao/domain/TradeConfirmFee.php | 25 + extend/taobao/domain/Video.php | 45 ++ extend/taobao/domain/WordMapData.php | 20 + extend/taobao/domain/Youjiacouponinfo.php | 20 + extend/taobao/request/AppipGetRequest.php | 32 + extend/taobao/request/AreasGetRequest.php | 48 ++ .../BaichuanOpenaccountLoginRequest.php | 47 ++ ...BaichuanOpenaccountLoginbytokenRequest.php | 47 ++ ...huanOpenaccountLogindoublecheckRequest.php | 47 ++ ...nOpenaccountNewlogindoublecheckRequest.php | 47 ++ ...aichuanOpenaccountPasswordResetRequest.php | 47 ++ .../BaichuanOpenaccountRegisterRequest.php | 47 ++ ...uanOpenaccountRegistercodeCheckRequest.php | 47 ++ ...huanOpenaccountRegistercodeSendRequest.php | 47 ++ ...ichuanOpenaccountResetcodeCheckRequest.php | 47 ++ ...aichuanOpenaccountResetcodeSendRequest.php | 47 ++ .../request/BaichuanOrderurlGetRequest.php | 47 ++ .../request/BaichuanPayresultQueryRequest.php | 47 ++ .../request/BaichuanTaokeTraceRequest.php | 47 ++ .../request/BaichuanUserLoginRequest.php | 47 ++ .../BaichuanUserLoginbytokenRequest.php | 47 ++ .../BaichuanUserLogindoublecheckRequest.php | 47 ++ .../CloudpushMessageAndroidRequest.php | 82 +++ .../request/CloudpushMessageIosRequest.php | 82 +++ .../request/CloudpushNoticeAndroidRequest.php | 99 +++ .../request/CloudpushNoticeIosRequest.php | 115 +++ .../taobao/request/CloudpushPushRequest.php | 374 ++++++++++ extend/taobao/request/FilesGetRequest.php | 81 +++ extend/taobao/request/HttpdnsGetRequest.php | 32 + .../taobao/request/ItemImgDeleteRequest.php | 81 +++ .../taobao/request/ItemImgUploadRequest.php | 128 ++++ extend/taobao/request/ItemJointImgRequest.php | 129 ++++ .../request/ItemJointPropimgRequest.php | 114 +++ extend/taobao/request/ItemSkusGetRequest.php | 66 ++ .../request/ItemUpdateDelistingRequest.php | 49 ++ .../request/ItemUpdateListingRequest.php | 67 ++ .../request/ItempropvaluesGetRequest.php | 131 ++++ .../request/KfcKeywordSearchRequest.php | 85 +++ .../request/OpenAccountCreateRequest.php | 47 ++ .../request/OpenAccountDeleteRequest.php | 65 ++ .../request/OpenAccountIndexFindRequest.php | 63 ++ .../taobao/request/OpenAccountListRequest.php | 65 ++ .../request/OpenAccountSearchRequest.php | 48 ++ .../request/OpenAccountTokenApplyRequest.php | 127 ++++ .../OpenAccountTokenValidateRequest.php | 48 ++ .../request/OpenAccountUpdateRequest.php | 47 ++ .../request/OpenuidGetBymixnickRequest.php | 48 ++ .../request/OpenuidGetBytradeRequest.php | 48 ++ extend/taobao/request/OpenuidGetRequest.php | 32 + extend/taobao/request/ProductAddRequest.php | 277 ++++++++ extend/taobao/request/ProductGetRequest.php | 96 +++ .../request/ProductImgUploadRequest.php | 113 +++ .../request/ProductPropimgUploadRequest.php | 114 +++ .../taobao/request/ProductUpdateRequest.php | 192 +++++ .../taobao/request/ProductsSearchRequest.php | 227 ++++++ extend/taobao/request/TbkCouponGetRequest.php | 79 +++ .../request/TbkDgNewuserOrderGetRequest.php | 128 ++++ .../request/TbkDgNewuserOrderSumRequest.php | 132 ++++ .../request/TbkDgOptimusMaterialRequest.php | 209 ++++++ .../request/TbkDgOptimusPromotionRequest.php | 97 +++ .../taobao/request/TbkItemInfoGetRequest.php | 147 ++++ extend/taobao/request/TimeGetRequest.php | 32 + .../request/TopAuthTokenCreateRequest.php | 64 ++ .../request/TopAuthTokenRefreshRequest.php | 48 ++ extend/taobao/request/TopIpoutGetRequest.php | 32 + .../request/TopSdkFeedbackUploadRequest.php | 64 ++ extend/taobao/request/TopSecretGetRequest.php | 80 +++ .../request/TopSecretRegisterRequest.php | 32 + .../request/TradeConfirmfeeGetRequest.php | 48 ++ extend/taobao/security/MagicCrypt.php | 51 ++ extend/taobao/security/README.txt | 8 + extend/taobao/security/SecretContext.php | 61 ++ extend/taobao/security/SecretCounterUtil.php | 97 +++ extend/taobao/security/SecretGetRequest.php | 35 + extend/taobao/security/SecurityClient.php | 543 +++++++++++++++ extend/taobao/security/SecurityTest.php | 68 ++ extend/taobao/security/SecurityUtil.php | 589 ++++++++++++++++ .../security/TopSdkFeedbackUploadRequest.php | 62 ++ extend/taobao/security/YacCache.php | 38 + extend/taobao/security/iCache.php | 14 + extend/taobao/top/.DS_Store | Bin 0 -> 8196 bytes route/api.php | 1 + 145 files changed, 12017 insertions(+), 55 deletions(-) create mode 100644 app/common/service/TopClient.php create mode 100644 extend/taobao/ApplicationVar.php create mode 100644 extend/taobao/Autoloader.php create mode 100644 extend/taobao/ClusterTopClient.php create mode 100644 extend/taobao/HttpdnsGetRequest.php create mode 100644 extend/taobao/LtInflector.php create mode 100644 extend/taobao/QimenCloud/QimenCloudClient.php create mode 100644 extend/taobao/RequestCheckUtil.php create mode 100644 extend/taobao/ResultSet.php create mode 100644 extend/taobao/SpiUtils.php create mode 100644 extend/taobao/TopLogger.php create mode 100644 extend/taobao/TopSdk.php create mode 100644 extend/taobao/__MACOSX/._Autoloader.php create mode 100644 extend/taobao/__MACOSX/._TopSdk.php create mode 100644 extend/taobao/__MACOSX/QimenCloud/._QimenCloudClient.php create mode 100644 extend/taobao/__MACOSX/top/._.DS_Store create mode 100644 extend/taobao/__MACOSX/top/._ApplicationVar.php create mode 100644 extend/taobao/__MACOSX/top/._SpiUtils.php create mode 100644 extend/taobao/__MACOSX/top/._TopClient.php create mode 100644 extend/taobao/__MACOSX/top/._fileTest.php create mode 100644 extend/taobao/aliyun/AliyunClient.php create mode 100644 extend/taobao/dingtalk/DingTalkClient.php create mode 100644 extend/taobao/dingtalk/DingTalkConstant.php create mode 100644 extend/taobao/domain/Area.php create mode 100644 extend/taobao/domain/BybtInfoDTO.php create mode 100644 extend/taobao/domain/Data.php create mode 100644 extend/taobao/domain/FavoritesDetail.php create mode 100644 extend/taobao/domain/FavoritesInfo.php create mode 100644 extend/taobao/domain/Feature.php create mode 100644 extend/taobao/domain/Item.php create mode 100644 extend/taobao/domain/ItemImg.php create mode 100644 extend/taobao/domain/KfcSearchResult.php create mode 100644 extend/taobao/domain/Location.php create mode 100644 extend/taobao/domain/MaifanPromotionDTO.php create mode 100644 extend/taobao/domain/MapData.php create mode 100644 extend/taobao/domain/NTbkItem.php create mode 100644 extend/taobao/domain/OAuthOtherInfo.php create mode 100644 extend/taobao/domain/OpenAccount.php create mode 100644 extend/taobao/domain/OpenAccountResult.php create mode 100644 extend/taobao/domain/OpenAccountSearchResult.php create mode 100644 extend/taobao/domain/OpenAccountTokenApplyResult.php create mode 100644 extend/taobao/domain/OpenAccountTokenValidateResult.php create mode 100644 extend/taobao/domain/OpenaccountLong.php create mode 100644 extend/taobao/domain/OpenaccountObject.php create mode 100644 extend/taobao/domain/OpenaccountVoid.php create mode 100644 extend/taobao/domain/OrderData.php create mode 100644 extend/taobao/domain/Product.php create mode 100644 extend/taobao/domain/ProductImg.php create mode 100644 extend/taobao/domain/ProductPropImg.php create mode 100644 extend/taobao/domain/PromotionExtend.php create mode 100644 extend/taobao/domain/PromotionList.php create mode 100644 extend/taobao/domain/PropImg.php create mode 100644 extend/taobao/domain/PropValue.php create mode 100644 extend/taobao/domain/RecommendItemList.php create mode 100644 extend/taobao/domain/Results.php create mode 100644 extend/taobao/domain/Sku.php create mode 100644 extend/taobao/domain/SpCampaign.php create mode 100644 extend/taobao/domain/TokenInfo.php create mode 100644 extend/taobao/domain/TokenInfoExt.php create mode 100644 extend/taobao/domain/TopDownloadRecordDo.php create mode 100644 extend/taobao/domain/TopNInfoDTO.php create mode 100644 extend/taobao/domain/TradeConfirmFee.php create mode 100644 extend/taobao/domain/Video.php create mode 100644 extend/taobao/domain/WordMapData.php create mode 100644 extend/taobao/domain/Youjiacouponinfo.php create mode 100644 extend/taobao/request/AppipGetRequest.php create mode 100644 extend/taobao/request/AreasGetRequest.php create mode 100644 extend/taobao/request/BaichuanOpenaccountLoginRequest.php create mode 100644 extend/taobao/request/BaichuanOpenaccountLoginbytokenRequest.php create mode 100644 extend/taobao/request/BaichuanOpenaccountLogindoublecheckRequest.php create mode 100644 extend/taobao/request/BaichuanOpenaccountNewlogindoublecheckRequest.php create mode 100644 extend/taobao/request/BaichuanOpenaccountPasswordResetRequest.php create mode 100644 extend/taobao/request/BaichuanOpenaccountRegisterRequest.php create mode 100644 extend/taobao/request/BaichuanOpenaccountRegistercodeCheckRequest.php create mode 100644 extend/taobao/request/BaichuanOpenaccountRegistercodeSendRequest.php create mode 100644 extend/taobao/request/BaichuanOpenaccountResetcodeCheckRequest.php create mode 100644 extend/taobao/request/BaichuanOpenaccountResetcodeSendRequest.php create mode 100644 extend/taobao/request/BaichuanOrderurlGetRequest.php create mode 100644 extend/taobao/request/BaichuanPayresultQueryRequest.php create mode 100644 extend/taobao/request/BaichuanTaokeTraceRequest.php create mode 100644 extend/taobao/request/BaichuanUserLoginRequest.php create mode 100644 extend/taobao/request/BaichuanUserLoginbytokenRequest.php create mode 100644 extend/taobao/request/BaichuanUserLogindoublecheckRequest.php create mode 100644 extend/taobao/request/CloudpushMessageAndroidRequest.php create mode 100644 extend/taobao/request/CloudpushMessageIosRequest.php create mode 100644 extend/taobao/request/CloudpushNoticeAndroidRequest.php create mode 100644 extend/taobao/request/CloudpushNoticeIosRequest.php create mode 100644 extend/taobao/request/CloudpushPushRequest.php create mode 100644 extend/taobao/request/FilesGetRequest.php create mode 100644 extend/taobao/request/HttpdnsGetRequest.php create mode 100644 extend/taobao/request/ItemImgDeleteRequest.php create mode 100644 extend/taobao/request/ItemImgUploadRequest.php create mode 100644 extend/taobao/request/ItemJointImgRequest.php create mode 100644 extend/taobao/request/ItemJointPropimgRequest.php create mode 100644 extend/taobao/request/ItemSkusGetRequest.php create mode 100644 extend/taobao/request/ItemUpdateDelistingRequest.php create mode 100644 extend/taobao/request/ItemUpdateListingRequest.php create mode 100644 extend/taobao/request/ItempropvaluesGetRequest.php create mode 100644 extend/taobao/request/KfcKeywordSearchRequest.php create mode 100644 extend/taobao/request/OpenAccountCreateRequest.php create mode 100644 extend/taobao/request/OpenAccountDeleteRequest.php create mode 100644 extend/taobao/request/OpenAccountIndexFindRequest.php create mode 100644 extend/taobao/request/OpenAccountListRequest.php create mode 100644 extend/taobao/request/OpenAccountSearchRequest.php create mode 100644 extend/taobao/request/OpenAccountTokenApplyRequest.php create mode 100644 extend/taobao/request/OpenAccountTokenValidateRequest.php create mode 100644 extend/taobao/request/OpenAccountUpdateRequest.php create mode 100644 extend/taobao/request/OpenuidGetBymixnickRequest.php create mode 100644 extend/taobao/request/OpenuidGetBytradeRequest.php create mode 100644 extend/taobao/request/OpenuidGetRequest.php create mode 100644 extend/taobao/request/ProductAddRequest.php create mode 100644 extend/taobao/request/ProductGetRequest.php create mode 100644 extend/taobao/request/ProductImgUploadRequest.php create mode 100644 extend/taobao/request/ProductPropimgUploadRequest.php create mode 100644 extend/taobao/request/ProductUpdateRequest.php create mode 100644 extend/taobao/request/ProductsSearchRequest.php create mode 100644 extend/taobao/request/TbkCouponGetRequest.php create mode 100644 extend/taobao/request/TbkDgNewuserOrderGetRequest.php create mode 100644 extend/taobao/request/TbkDgNewuserOrderSumRequest.php create mode 100644 extend/taobao/request/TbkDgOptimusMaterialRequest.php create mode 100644 extend/taobao/request/TbkDgOptimusPromotionRequest.php create mode 100644 extend/taobao/request/TbkItemInfoGetRequest.php create mode 100644 extend/taobao/request/TimeGetRequest.php create mode 100644 extend/taobao/request/TopAuthTokenCreateRequest.php create mode 100644 extend/taobao/request/TopAuthTokenRefreshRequest.php create mode 100644 extend/taobao/request/TopIpoutGetRequest.php create mode 100644 extend/taobao/request/TopSdkFeedbackUploadRequest.php create mode 100644 extend/taobao/request/TopSecretGetRequest.php create mode 100644 extend/taobao/request/TopSecretRegisterRequest.php create mode 100644 extend/taobao/request/TradeConfirmfeeGetRequest.php create mode 100644 extend/taobao/security/MagicCrypt.php create mode 100644 extend/taobao/security/README.txt create mode 100644 extend/taobao/security/SecretContext.php create mode 100644 extend/taobao/security/SecretCounterUtil.php create mode 100644 extend/taobao/security/SecretGetRequest.php create mode 100644 extend/taobao/security/SecurityClient.php create mode 100644 extend/taobao/security/SecurityTest.php create mode 100644 extend/taobao/security/SecurityUtil.php create mode 100644 extend/taobao/security/TopSdkFeedbackUploadRequest.php create mode 100644 extend/taobao/security/YacCache.php create mode 100644 extend/taobao/security/iCache.php create mode 100644 extend/taobao/top/.DS_Store diff --git a/app/common/service/TopClient.php b/app/common/service/TopClient.php new file mode 100644 index 00000000..872a1e8b --- /dev/null +++ b/app/common/service/TopClient.php @@ -0,0 +1,385 @@ +appkey; + } + + 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_array($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("@" != 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 (Extend $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 (Extend $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/app/controller/api/Auth.php b/app/controller/api/Auth.php index 452041f0..4b9f84ef 100644 --- a/app/controller/api/Auth.php +++ b/app/controller/api/Auth.php @@ -53,8 +53,11 @@ use crmeb\jobs\TestJob; use crmeb\services\PayService; use crmeb\services\CombinePayService; use app\common\model\user\User; - +use app\common\service\TopClient; use app\controller\api\Ceshi; +use taobao\request\TbkItemInfoGetRequest; +use app\common\repositories\store\product\ProductRepository; +use think\facade\App; /** * Class Auth @@ -64,11 +67,113 @@ use app\controller\api\Ceshi; */ class Auth extends BaseController { + public function caiji() + { + $url=$this->request->host(); + $parmas = $this->request->param(); + $query=parse_url($parmas['url']); + $itemId=$this->convertUrlQuery($query['query']); + $c = new TopClient; + $c->appkey = '34537213'; + $c->secretKey = '4a35f3657156580c1f533750295c54c4'; + $req = new TbkItemInfoGetRequest; + $req->setNumIids($itemId['itemId']); + $resp = $c->execute($req); + $res=$resp->results->n_tbk_item; + $images=[]; + $filename = basename($res->pict_url); // 获取文件名 + $destination = public_path('uploads').'img/' . $filename; // 目标路径 + $pict_url= $url.'/uploads/img/'.$filename; + file_put_contents($destination, file_get_contents($res->pict_url)); + + if($resp && isset($resp->small_images) && isset($resp->small_images->string)){ + foreach($resp->small_images->string as $k=>$v){ + $filename = basename($v); // 获取文件名 + $destination = public_path('uploads').'img/' . $filename; // 目标路径 + file_put_contents($destination, file_get_contents($v)); + $images[]=$url.'/uploads/img/'.$filename; + } + } + $data=[ + "image" => $pict_url, + "slider_image" =>$images, + "store_name" => json_decode(json_encode($res->title),true)[0], + "store_info" => json_decode(json_encode($res->cat_leaf_name),true)[0], + "keyword" => "", + "bar_code" => "", + "guarantee_template_id" => "", + "cate_id" => $parmas['cate_id'], + "mer_cate_id" => [], + "unit_name" => $parmas['unit_name'], + "sort" => 0, + "is_show" => "", + "is_good" => 0, + "is_gift_bag" => 0, + "integral_rate" => -1, + "video_link" => "", + "temp_id" => 399, + "content" => $images, + "spec_type" => 0, + "extension_type" => 0, + "attr" => [], + "mer_labels" => [], + "delivery_way" => [ + 0 => "1", + 1 => "2" + ], + "delivery_free" => 0, + "param_temp_id" => [], + "extend" => [], + "source_product_id" => "", + "stock" => "100", + "brand_id" => "", + "once_max_count" => 0, + "once_min_count" => 0, + "pay_limit" => 0, + "attrValue" => [ + 0 => [ + "image" => $pict_url, + "price" => bcsub($res->reserve_price,($res->reserve_price*0.05),2), + "cost" => 0, + "ot_price" => 0, + "svip_price" => null, + "stock" => 100, + "bar_code" => "", + "weight" => 0, + "volume" => 0, + ], + ], + "give_coupon_ids" => [], + "type" => 0, + "svip_price" => 0, + "svip_price_type" => 0, + "params" => [], + "mer_id" => $parmas['mer_id'], + "status" => 0, + "mer_status" => 1, + "rate" => 3, + ]; + $a= app()->make( ProductRepository::class)->create($data,0,1); + // 下载图片并保存到目标路径 + return app('json')->success($a); + } + function convertUrlQuery($query) + { + $queryParts = explode('&', $query); + + $params = array(); + foreach ($queryParts as $param) { + $item = explode('=', $param); + $params[$item[0]] = $item[1]; + } + + return $params; + } public function dotest() { $data = [ "tempId" => "ADMIN_PAY_SUCCESS_CODE", - "id" => 113 + "id" => 113 ]; try { $client = app()->make(JgPush::class); @@ -84,7 +189,7 @@ class Auth extends BaseController public function test() { $type = $this->request->param('type'); - $res=[]; + $res = []; switch ($type) { case 1: $res = (app()->make(Ceshi::class))->Merchant_reconciliation_download(); @@ -109,21 +214,21 @@ class Auth extends BaseController break; } return app('json')->success(json_decode($res, true)); -// $data = [ -// 'tempId' => '', -// 'id' => '', -// ]; -// Queue::push(SendSmsJob::class,$data); -// $status = app()->make(SystemNoticeConfigRepository::class)->getNoticeStatusByConstKey($data['tempId']); -// if ($status['notice_sms'] == 1) { -// SmsService::sendMessage($data); -// } -// if ($status['notice_wechat'] == 1) { -// app()->make(WechatTemplateMessageService::class)->sendTemplate($data); -// } -// if ($status['notice_routine'] == 1) { -// app()->make(WechatTemplateMessageService::class)->subscribeSendTemplate($data); -// } + // $data = [ + // 'tempId' => '', + // 'id' => '', + // ]; + // Queue::push(SendSmsJob::class,$data); + // $status = app()->make(SystemNoticeConfigRepository::class)->getNoticeStatusByConstKey($data['tempId']); + // if ($status['notice_sms'] == 1) { + // SmsService::sendMessage($data); + // } + // if ($status['notice_wechat'] == 1) { + // app()->make(WechatTemplateMessageService::class)->sendTemplate($data); + // } + // if ($status['notice_routine'] == 1) { + // app()->make(WechatTemplateMessageService::class)->subscribeSendTemplate($data); + // } } /** @@ -142,9 +247,9 @@ class Auth extends BaseController if (!$account) return app('json')->fail('请输入账号'); $user = $repository->accountByUser($this->request->param('account')); -// if($auth_token && $user){ -// return app('json')->fail('用户已存在'); -// } + // if($auth_token && $user){ + // return app('json')->fail('用户已存在'); + // } if (!$user) $this->loginFailure($account); if (!password_verify($pwd = (string)$this->request->param('password'), $user['pwd'])) $this->loginFailure($account); $auth = $this->parseAuthToken($auth_token); @@ -176,7 +281,6 @@ class Auth extends BaseController $fail_key = 'api_login_freeze_' . $account; Cache::set($fail_key, 1, 15 * 60); throw new ValidateException('账号或密码错误次数太多,请稍后在尝试'); - } else { Cache::set($key, $numb, 5 * 60); @@ -225,7 +329,7 @@ class Auth extends BaseController // 判断是否是商户,并且有没有完善信息 // 这里有点小问题以后要修改 $store_service = Db::name('store_service')->where('uid', $data['uid'])->find(); - + if ($store_service) { $mer_arr = Db::name('merchant')->where('mer_id', $store_service['mer_id'])->where('is_del', 0)->field('type_id,mer_avatar,mer_banner,business_status,mer_info,category_id,service_phone,mer_address,uid,mer_name,create_time,update_time,mer_settlement_agree_status,is_margin,street_id')->find(); if ($mer_arr && $mer_arr['mer_avatar'] != '' && $mer_arr['mer_banner'] != '' && $mer_arr['mer_info'] && $mer_arr['service_phone'] != '' && $mer_arr['mer_address'] != '') { @@ -245,7 +349,7 @@ class Auth extends BaseController $thirdparty = Db::name('user_thirdparty_token')->where('user_id', $user->uid)->select(); $thirdList = []; - foreach($thirdparty as $v) { + foreach ($thirdparty as $v) { $temp = [ 'account' => $v['account'], 'user_type' => $v['user_type'], @@ -279,16 +383,16 @@ class Auth extends BaseController if (!$merchant) { return app('json')->fail('没有店铺'); } - if($merchant['is_margin'] == 10){ + if ($merchant['is_margin'] == 10) { return app('json')->fail('保证金已缴纳'); } - if($merchant['margin'] == 0){ + if ($merchant['margin'] == 0) { $margin = Db::name('MerchantType')->where('mer_type_id', $merchant['type_id'])->value('margin'); - $margin = bcsub($margin,$merchant['paid_margin'],2); - }else{ - $margin=$merchant['margin']; + $margin = bcsub($margin, $merchant['paid_margin'], 2); + } else { + $margin = $merchant['margin']; } - if($margin==0){ + if ($margin == 0) { return app('json')->fail('当前金额为0,不能进行充值'); } $orderSn = "bzj" . date('YmdHis') . uniqid(); @@ -313,7 +417,7 @@ class Auth extends BaseController ]; $payType = 'weixinApp'; $service = new PayService($payType, $param); - $payInfo = $service->pay(User::where(['uid'=>$user['uid']])->find()); + $payInfo = $service->pay(User::where(['uid' => $user['uid']])->find()); return app('json')->success($payInfo); } @@ -321,8 +425,8 @@ class Auth extends BaseController { $user = $this->request->userInfo(); [$page, $limit] = $this->getPage(); - $count = Db::name('margin_order')->where('uid', $user['uid'])->where('paid',1)->count(); - $list = Db::name('margin_order')->where('uid', $user['uid'])->where('paid',1)->page($page, $limit)->order('order_id', 'desc')->select()->toArray(); + $count = Db::name('margin_order')->where('uid', $user['uid'])->where('paid', 1)->count(); + $list = Db::name('margin_order')->where('uid', $user['uid'])->where('paid', 1)->page($page, $limit)->order('order_id', 'desc')->select()->toArray(); return app('json')->success(compact('count', 'list')); } @@ -552,7 +656,7 @@ class Auth extends BaseController if ($sms_limit && $limit > $sms_limit) { return app('json')->fail('请求太频繁请稍后再试'); } -// if(!env('APP_DEBUG', false)){ + // if(!env('APP_DEBUG', false)){ try { $sms_code = str_pad(random_int(1, 9999), 4, 0, STR_PAD_LEFT); $sms_time = systemConfig('sms_time') ? systemConfig('sms_time') : 30; @@ -560,10 +664,10 @@ class Auth extends BaseController } catch (Exception $e) { return app('json')->fail($e->getMessage()); } -// }else{ -// $sms_code = 1234; -// $sms_time = 5; -// } + // }else{ + // $sms_code = 1234; + // $sms_time = 5; + // } $sms_key = app()->make(SmsService::class)->sendSmsKey($data['phone'], $data['type']); Cache::set($sms_key, $sms_code, $sms_time * 60); Cache::set($sms_limit_key, $limit + 1, 60); @@ -889,9 +993,9 @@ class Auth extends BaseController $phone = $data['purePhoneNumber']; $user = $userRepository->accountByUser($phone); -// if($user && $auth_token){ -// return app('json')->fail('用户已存在'); -// } + // if($user && $auth_token){ + // return app('json')->fail('用户已存在'); + // } $auth = $this->parseAuthToken($auth_token); if ($user && $auth) { $userRepository->syncBaseAuth($auth, $user); @@ -1026,7 +1130,7 @@ class Auth extends BaseController $merIdArray = $queryMerBuilder->fetchSql(false)->column('mer_id'); $queryBuilder = $queryBuilder->whereIn('mer_id', $merIdArray); if ($cityCode) { - $cityCodeArray = explode(',', $cityCode ); + $cityCodeArray = explode(',', $cityCode); if (count($cityCodeArray) == 1) { $queryBuilder = $queryBuilder->where('city_code', $cityCode); } @@ -1114,7 +1218,7 @@ class Auth extends BaseController $merIdArray = $queryMerBuilder->fetchSql(false)->column('mer_id'); $queryBuilder = $queryBuilder->whereIn('mer_id', $merIdArray); if ($cityCode) { - $cityCodeArray = explode(',', $cityCode ); + $cityCodeArray = explode(',', $cityCode); if (count($cityCodeArray) == 1) { $queryBuilder = $queryBuilder->where('city_code', $cityCode); } @@ -1174,7 +1278,7 @@ class Auth extends BaseController } $list = $list->toArray(); }; - foreach($list as $k=>$v) { + foreach ($list as $k => $v) { $list[$k]['order_sn'] = !empty($orderIdList[$v['order_id']]) ? $orderIdList[$v['order_id']] : ''; } return app('json')->success(compact('count', 'list')); @@ -1240,7 +1344,7 @@ class Auth extends BaseController 'where' => $this->request->param(), 'mer_num' => $merNum ]; - return app('json')->success($data); + return app('json')->success($data); } //根据地址信息查询商品数 @@ -1319,7 +1423,7 @@ class Auth extends BaseController $expiresTime = $this->request->param('expires_time', ''); $user = $this->request->userInfo(); $uid = $user->uid; - $tokenInfo = Db::name('user_thirdparty_token')->where(['user_type'=>$userType, 'user_id'=>$uid])->find(); + $tokenInfo = Db::name('user_thirdparty_token')->where(['user_type' => $userType, 'user_id' => $uid])->find(); if ($tokenInfo) { $updData = [ 'account' => $account, @@ -1327,7 +1431,7 @@ class Auth extends BaseController 'expires_time' => $expiresTime, 'create_time' => date('Y-m-d H:i:s') ]; - Db::name('user_thirdparty_token')->where(['user_type'=>$userType, 'user_id'=>$uid])->update($updData); + Db::name('user_thirdparty_token')->where(['user_type' => $userType, 'user_id' => $uid])->update($updData); } else { $insertData = [ 'user_id' => $uid, @@ -1415,8 +1519,8 @@ class Auth extends BaseController $phoneBrand = $this->request->param('phone_brand', ''); $queryBuilder = Db::name('AppUpdate')->where('type', $type); if ($type == 3) { - $android = (Db::name('AppUpdate')->where('type', 1)->where('phone_brand','')->order('id', 'desc')->find()) ?? (object)[]; - $ios = (Db::name('AppUpdate')->where('type', 2)->where('phone_brand','')->order('id', 'desc')->find()) ?? (object)[]; + $android = (Db::name('AppUpdate')->where('type', 1)->where('phone_brand', '')->order('id', 'desc')->find()) ?? (object)[]; + $ios = (Db::name('AppUpdate')->where('type', 2)->where('phone_brand', '')->order('id', 'desc')->find()) ?? (object)[]; return app('json')->success(compact('android', 'ios')); } else { if ($version) { @@ -1424,7 +1528,7 @@ class Auth extends BaseController } if ($phoneBrand) { $spos = false; - foreach($brandArray as $b) { + foreach ($brandArray as $b) { $pos = stripos($phoneBrand, $b); if ($pos !== false) { $spos = true; @@ -1440,7 +1544,7 @@ class Auth extends BaseController $appInfo = (Db::name('AppUpdate')->where('type', $type)->where('version', '>', $version)->find()) ?? (object)[]; } } - + return app('json')->success(compact('appInfo')); } @@ -1452,7 +1556,7 @@ class Auth extends BaseController Log::info("同步商户申请状态数据:" . json_encode(request()->param())); $repository = app()->make(MerchantIntentionRepository::class); if (!$repository->getWhereCount(['mer_intention_id' => $id, 'is_del' => 0])) - return app('json')->fail('数据不存在'); + return app('json')->fail('数据不存在'); $status = $this->request->post('status', 0); $remark = $this->request->post('remark', ''); $type = $this->request->post('type', 1); @@ -1469,7 +1573,7 @@ class Auth extends BaseController $repository->updateStatus($id, $data); $intention = Db::name('merchant_intention')->where('mer_intention_id', $id)->where('type', 1)->find(); $merLicenseImage = ''; - if (!empty($intention['images'])) { + if (!empty($intention['images'])) { $merLicenseImageArray = explode(',', $intention['images']); $merLicenseImage = $merLicenseImageArray[0] ?? ''; } @@ -1493,10 +1597,10 @@ class Auth extends BaseController $merId = Db::name('merchant_intention')->where('mer_intention_id', $id)->where('type', 2)->value('mer_id', 0); Db::name('merchant')->where('mer_id', $merId)->where('status', 1)->update(['business_status' => ($status == 1 ? 2 : 3)]); if ($status == 1) { - Db::name('merchant')->where('mer_id', $merId)->update(['mer_settlement_agree_status'=>1]); + Db::name('merchant')->where('mer_id', $merId)->update(['mer_settlement_agree_status' => 1]); } } - + return app('json')->success('同步成功'); } diff --git a/app/controller/merchant/store/product/Product.php b/app/controller/merchant/store/product/Product.php index e2701fa5..b1c4e2f4 100644 --- a/app/controller/merchant/store/product/Product.php +++ b/app/controller/merchant/store/product/Product.php @@ -98,6 +98,7 @@ class Product extends BaseController $product_type=0;//普通商品 } $data['update_time'] = date('Y-m-d H:i:s'); + halt($data); $this->repository->create($data,$product_type,1); return app('json')->success('添加成功'); } diff --git a/extend/taobao/ApplicationVar.php b/extend/taobao/ApplicationVar.php new file mode 100644 index 00000000..528b2ba1 --- /dev/null +++ b/extend/taobao/ApplicationVar.php @@ -0,0 +1,47 @@ +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/extend/taobao/Autoloader.php b/extend/taobao/Autoloader.php new file mode 100644 index 00000000..1cda18f1 --- /dev/null +++ b/extend/taobao/Autoloader.php @@ -0,0 +1,78 @@ + \ No newline at end of file diff --git a/extend/taobao/ClusterTopClient.php b/extend/taobao/ClusterTopClient.php new file mode 100644 index 00000000..8d1ca000 --- /dev/null +++ b/extend/taobao/ClusterTopClient.php @@ -0,0 +1,199 @@ +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/extend/taobao/HttpdnsGetRequest.php b/extend/taobao/HttpdnsGetRequest.php new file mode 100644 index 00000000..13adcf0e --- /dev/null +++ b/extend/taobao/HttpdnsGetRequest.php @@ -0,0 +1,23 @@ +apiParas; + } + + public function check(){} + + public function putOtherTextParam($key, $value) { + $this->apiParas[$key] = $value; + $this->$key = $value; + } +} diff --git a/extend/taobao/LtInflector.php b/extend/taobao/LtInflector.php new file mode 100644 index 00000000..811827ef --- /dev/null +++ b/extend/taobao/LtInflector.php @@ -0,0 +1,18 @@ + "_"); + + public function camelize($uncamelized_words) + { + $uncamelized_words = $this->conf["separator"] . str_replace($this->conf["separator"] , " ", strtolower($uncamelized_words)); + return ltrim(str_replace(" ", "", ucwords($uncamelized_words)), $this->conf["separator"] ); + } + + public function uncamelize($camelCaps) + { + return strtolower(preg_replace('/([a-z])([A-Z])/', "$1" . $this->conf["separator"] . "$2", $camelCaps)); + } +} \ No newline at end of file diff --git a/extend/taobao/QimenCloud/QimenCloudClient.php b/extend/taobao/QimenCloud/QimenCloudClient.php new file mode 100644 index 00000000..572cb873 --- /dev/null +++ b/extend/taobao/QimenCloud/QimenCloudClient.php @@ -0,0 +1,384 @@ +appkey; + } + + 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_array($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("@" != 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) + { + if($this->gatewayUrl == null) { + throw new Exception("client-check-error:Need Set gatewayUrl.", 40); + } + + $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"); + $sysParams["target_app_key"] = $this->targetAppkey; + 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/extend/taobao/RequestCheckUtil.php b/extend/taobao/RequestCheckUtil.php new file mode 100644 index 00000000..4120661d --- /dev/null +++ b/extend/taobao/RequestCheckUtil.php @@ -0,0 +1,111 @@ + $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/extend/taobao/ResultSet.php b/extend/taobao/ResultSet.php new file mode 100644 index 00000000..273a1250 --- /dev/null +++ b/extend/taobao/ResultSet.php @@ -0,0 +1,22 @@ + $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']; // 只获取参与签名的头部字段 + + if(!$signList) { + return $headerMap; + } + + $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\w+)\[(?P\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.") || self::startsWith($remoteIp,"40.205.145."); + } + + private static function getFormMap(){ + $resultArray = array(); + foreach($_POST as $key=>$v) { + $resultArray[$key] = $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/extend/taobao/TopLogger.php b/extend/taobao/TopLogger.php new file mode 100644 index 00000000..04a53394 --- /dev/null +++ b/extend/taobao/TopLogger.php @@ -0,0 +1,45 @@ + "\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/extend/taobao/TopSdk.php b/extend/taobao/TopSdk.php new file mode 100644 index 00000000..a7971677 --- /dev/null +++ b/extend/taobao/TopSdk.php @@ -0,0 +1,40 @@ +$Vqox1Ojhs@R)|o50+1L3ClDI}aUBqY_#1$j2;dkJ5(HHS(y;)D1)zKw z#Rz090AirHRC0c$Vqox1Ojhs@R)|o50+1L3ClDI}aUBqY_#1$j2;dkJ5(HHS(y;)D1)zKw z#Rz090AirHRC0c$Vqox1Ojhs@R)|o50+1L3ClDI}aUBqY_#1$j2;dkJ5(HHS(y;)D1)zKw z#Rz090AirHRC0c$Vqox1Ojhs@R)|o50+1L3ClDI}u^SMB_!U6R08`;00ODZ-jv*mIP;rnB Iur73U08|YJ=l}o! literal 0 HcmV?d00001 diff --git a/extend/taobao/__MACOSX/top/._ApplicationVar.php b/extend/taobao/__MACOSX/top/._ApplicationVar.php new file mode 100644 index 0000000000000000000000000000000000000000..3525c1fa7a45c20002a96df603288eea271afa8f GIT binary patch literal 176 zcmZQz6=P>$Vqox1Ojhs@R)|o50+1L3ClDI}aUBqY_#1$j2;dkJ5(HHS(y;)D1)zKw z#Rz090AirHRC0c-OO*9lU literal 0 HcmV?d00001 diff --git a/extend/taobao/__MACOSX/top/._SpiUtils.php b/extend/taobao/__MACOSX/top/._SpiUtils.php new file mode 100644 index 0000000000000000000000000000000000000000..1b702ee0a07f8ef9562d25502f6e9839c5984f7c GIT binary patch literal 176 zcmZQz6=P>$Vqox1Ojhs@R)|o50+1L3ClDI}aUBqY_#1$j2;dkJ5(HHS(y;)D1)zKw z#Rz090AirHRC0cOV literal 0 HcmV?d00001 diff --git a/extend/taobao/__MACOSX/top/._TopClient.php b/extend/taobao/__MACOSX/top/._TopClient.php new file mode 100644 index 0000000000000000000000000000000000000000..05e121e71d89636a6a601dfb4021938d84e9dc31 GIT binary patch literal 176 zcmZQz6=P>$Vqox1Ojhs@R)|o50+1L3ClDI}aUBqY_#1$j2;dkJ5(HHS(y;)D1)zKw z#Rz090AirHRC0c$Vqox1Ojhs@R)|o50+1L3ClDI}aUBqY_#1$j2;dkJ5(HHS(y;)D1)zKw z#Rz090AirHRC0ccheckRequest) { + try { + $request->check(); + } catch (Exception $e) { + $result->code = $e->getCode(); + $result->message = $e->getMessage(); + return $result; + } + } + //获取业务参数 + $apiParams = $request->getApiParas(); + //组装系统参数 + $apiParams["AccessKeyId"] = $this->accessKeyId; + $apiParams["Format"] = $this->format;// + $apiParams["SignatureMethod"] = $this->signatureMethod; + $apiParams["SignatureVersion"] = $this->signatureVersion; + $apiParams["SignatureNonce"] = uniqid(); + date_default_timezone_set("GMT"); + $apiParams["TimeStamp"] = date($this->dateTimeFormat); + $apiParams["partner_id"] = $this->sdkVersion; + + $apiNameArray = split("\.", $request->getApiMethodName()); + $apiParams["Action"] = $apiNameArray[3]; + $apiParams["Version"] = $apiNameArray[4]; + //签名 + $apiParams["Signature"] = $this->computeSignature($apiParams, $this->accessKeySecret); + + //系统参数放入GET请求串 + $requestUrl = rtrim($this->serverUrl,"/") . "/?"; + foreach ($apiParams as $apiParamKey => $apiParamValue) + { + $requestUrl .= "$apiParamKey=" . urlencode($apiParamValue) . "&"; + } + $requestUrl = substr($requestUrl, 0, -1); + //发起HTTP请求 + try + { + $resp = $this->curl($requestUrl, null); + } + catch (Exception $e) + { + $this->logCommunicationError($apiParams["Action"],$requestUrl,"HTTP_ERROR_" . $e->getCode(),$e->getMessage()); + if ("json" == $this->format) + { + return json_decode($e->getMessage()); + } + else if("xml" == $this->format) + { + return @simplexml_load_string($e->getMessage()); + } + } + + //解析API返回结果 + $respWellFormed = false; + if ("json" == $this->format) + { + $respObject = json_decode($resp); + if (null !== $respObject) + { + $respWellFormed = true; + } + } + else if("xml" == $this->format) + { + $respObject = @simplexml_load_string($resp); + if (false !== $respObject) + { + $respWellFormed = true; + } + } + + //返回的HTTP文本不是标准JSON或者XML,记下错误日志 + if (false === $respWellFormed) + { + $this->logCommunicationError($apiParams["Action"],$requestUrl,"HTTP_RESPONSE_NOT_WELL_FORMED",$resp); + $result->code = 0; + $result->message = "HTTP_RESPONSE_NOT_WELL_FORMED"; + return $result; + } + + //如果TOP返回了错误码,记录到业务错误日志中 + if (isset($respObject->code)) + { + $logger = new LtLogger; + $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["Action"])) + { + trigger_error("No api name passed"); + } + $inflector = new LtInflector; + $inflector->conf["separator"] = "."; + $requestClassName = ucfirst($inflector->camelize(substr($paramsArray["Action"], 7))) . "Request"; + if (!class_exists($requestClassName)) + { + trigger_error("No such api: " . $paramsArray["Action"]); + } + + $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); + } + + protected function percentEncode($str) + { + // 使用urlencode编码后,将"+","*","%7E"做替换即满足 API规定的编码规范 + $res = urlencode($str); + $res = preg_replace('/\+/', '%20', $res); + $res = preg_replace('/\*/', '%2A', $res); + $res = preg_replace('/%7E/', '~', $res); + return $res; + } + + protected function computeSignature($parameters, $accessKeySecret) + { + // 将参数Key按字典顺序排序 + ksort($parameters); + + // 生成规范化请求字符串 + $canonicalizedQueryString = ''; + foreach($parameters as $key => $value) + { + $canonicalizedQueryString .= '&' . $this->percentEncode($key) + . '=' . $this->percentEncode($value); + } + + // 生成用于计算签名的字符串 stringToSign + $stringToSign = 'GET&%2F&' . $this->percentencode(substr($canonicalizedQueryString, 1)); + + // 计算签名,注意accessKeySecret后面要加上字符'&' + $signature = base64_encode(hash_hmac('sha1', $stringToSign, $accessKeySecret . '&', true)); + return $signature; + } + + 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); + } + //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("@" != substr($v, 0, 1))//判断是不是文件上传 + { + $postBodyString .= "$k=" . urlencode($v) . "&"; + } + else//文件上传用multipart/form-data,否则用www-form-urlencoded + { + $postMultipart = true; + } + } + unset($k, $v); + curl_setopt($ch, CURLOPT_POST, true); + if ($postMultipart) + { + curl_setopt($ch, CURLOPT_POSTFIELDS, $postFields); + } + else + { + curl_setopt($ch, CURLOPT_POSTFIELDS, substr($postBodyString,0,-1)); + } + } + $reponse = curl_exec($ch); + + if (curl_errno($ch)) + { + throw new Exception(curl_error($ch),0); + } + curl_close($ch); + return $reponse; + } + + protected function logCommunicationError($apiName, $requestUrl, $errorCode, $responseTxt) + { + $localIp = isset($_SERVER["SERVER_ADDR"]) ? $_SERVER["SERVER_ADDR"] : "CLI"; + $logger = new LtLogger; + $logger->conf["log_file"] = rtrim(TOP_SDK_WORK_DIR, '\\/') . '/' . "logs/top_comm_err_" . $this->accessKeyId . "_" . date("Y-m-d") . ".log"; + $logger->conf["separator"] = "^_^"; + $logData = array( + date("Y-m-d H:i:s"), + $apiName, + $this->accessKeyId, + $localIp, + PHP_OS, + $this->sdkVersion, + $requestUrl, + $errorCode, + str_replace("\n","",$responseTxt) + ); + $logger->log($logData); + } +} diff --git a/extend/taobao/dingtalk/DingTalkClient.php b/extend/taobao/dingtalk/DingTalkClient.php new file mode 100644 index 00000000..78e11ffa --- /dev/null +++ b/extend/taobao/dingtalk/DingTalkClient.php @@ -0,0 +1,656 @@ +apiCallType = $apiCallType; + $this->httpMethod = $httpMethod; + $this->format = $format; + } + + 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, "dingtalk-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("@" != 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_get($url,$apiFields = null) + { + $ch = curl_init(); + + foreach ($apiFields as $key => $value) + { + if(!is_string($value)){ + $value = json_encode($value); + } + $url .= "&" ."$key=" . urlencode($value); + } + + curl_setopt($ch, CURLOPT_URL, $url); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + curl_setopt($ch, CURLOPT_FAILONERROR, false); + curl_setopt($ch, CURLOPT_HEADER, false); + curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); + + + 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, "dingtalk-sdk-php" ); + + //https ignore ssl check ? + if(strlen($url) > 5 && strtolower(substr($url,0,5)) == "https" ) + { + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); + curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); + } + + $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_json($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, "dingtalk-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)){ + $v = json_encode($v); + } + 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/json; charset=utf-8", "Content-Length:".strlen(json_encode($postFields))); + curl_setopt($ch,CURLOPT_HTTPHEADER,$header); + curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($postFields)); + } + } + $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, "dingtalk-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['filename'] . "\" \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_" . "_" . date("Y-m-d") . ".log"; + $logger->conf["separator"] = "^_^"; + $logData = array( + date("Y-m-d H:i:s"), + $apiName, + $localIp, + PHP_OS, + $this->sdkVersion, + $requestUrl, + $errorCode, + str_replace("\n","",$responseTxt) + ); + $logger->log($logData); + } + + public function execute($request, $session = null,$bestUrl = null){ + if(DingTalkConstant::$CALL_TYPE_OAPI == $this->apiCallType){ + return $this->_executeOapi($request, $session, $bestUrl, null, null, null, null); + }else{ + return $this->_execute($request, $session, $bestUrl); + } + } + + public function executeWithAccessKey($request, $bestUrl = null, $accessKey, $accessSecret){ + return $this->executeWithCorpId($request, $bestUrl, $accessKey, $accessSecret, null, null); + } + + public function executeWithSuiteTicket($request,$bestUrl = null, $accessKey, $accessSecret, $suiteTicket){ + return $this->executeWithCorpId($request,$bestUrl, $accessKey, $accessSecret, $suiteTicket, null); + } + + public function executeWithCorpId($request, $bestUrl = null, $accessKey, $accessSecret, $suiteTicket, $corpId) { + if(DingTalkConstant::$CALL_TYPE_OAPI == $this->apiCallType){ + return $this->_executeOapi($request, null, $bestUrl,$accessKey, $accessSecret, $suiteTicket, $corpId); + }else{ + return $this->_execute($request, null, $bestUrl); + } + } + + private function _executeOapi($request, $session = null,$bestUrl = null,$accessKey, $accessSecret, $suiteTicket, $corpId){ + $result = new ResultSet(); + if($this->checkRequest) { + try { + $request->check(); + } catch (Exception $e) { + + $result->code = $e->getCode(); + $result->msg = $e->getMessage(); + return $result; + } + } + + $sysParams["method"] = $request->getApiMethodName(); + //系统参数放入GET请求串 + if($bestUrl){ + if(strpos($bestUrl,'?') === false){ + $requestUrl = $bestUrl."?"; + }else{ + $requestUrl = $bestUrl; + } + }else{ + $requestUrl = $this->gatewayUrl."?"; + } + if(null != $accessKey){ + $timestamp = $this->getMillisecond(); + // 验证签名有效性 + $canonicalString = $this->getCanonicalStringForIsv($timestamp, $suiteTicket); + $signature = $this->computeSignature($accessSecret, $canonicalString); + + $queryParams["accessKey"] = $accessKey; + $queryParams["signature"] = $signature; + $queryParams["timestamp"] = $timestamp+""; + if($suiteTicket != null) { + $queryParams["suiteTicket"] = $suiteTicket; + } + if($corpId != null){ + $queryParams["corpId"] = $corpId; + } + foreach ($queryParams as $queryParamKey => $queryParamValue) { + $requestUrl .= "$queryParamKey=" . urlencode($queryParamValue) . "&"; + } + }else{ + $requestUrl .= "access_token=" . urlencode($session) . "&"; + } + + $apiParams = array(); + //获取业务参数 + $apiParams = $request->getApiParas(); + $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{ + if(DingTalkConstant::$METHOD_POST == $this->httpMethod){ + $resp = $this->curl_json($requestUrl, $apiParams); + }else{ + $resp = $this->curl_get($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; + } + } + 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_" . "_" . date("Y-m-d") . ".log"; + $logger->log(array( + date("Y-m-d H:i:s"), + $resp + )); + } + return $respObject; + } + + private function getMillisecond() { + list($s1, $s2) = explode(' ', microtime()); + return (float)sprintf('%.0f', (floatval($s1) + floatval($s2)) * 1000); + } + + private function getCanonicalStringForIsv($timestamp, $suiteTicket) { + $result = $timestamp; + if($suiteTicket != null) { + $result .= "\n".$suiteTicket; + } + return $result; + } + + private function computeSignature($accessSecret, $canonicalString){ + $s = hash_hmac('sha256', $canonicalString, $accessSecret, true); + return base64_encode($s); + } + + private 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["v"] = $this->apiVersion; + $sysParams["format"] = $this->format; + $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){ + if(strpos($bestUrl,'?') === false){ + $requestUrl = $bestUrl."?"; + }else{ + $requestUrl = $bestUrl; + } + $sysParams["partner_id"] = $this->getClusterTag(); + }else{ + $requestUrl = $this->gatewayUrl."?"; + $sysParams["partner_id"] = $this->sdkVersion; + } + + 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_" . "_" . 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 dingtalk-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/extend/taobao/dingtalk/DingTalkConstant.php b/extend/taobao/dingtalk/DingTalkConstant.php new file mode 100644 index 00000000..f1ffad5f --- /dev/null +++ b/extend/taobao/dingtalk/DingTalkConstant.php @@ -0,0 +1,18 @@ + \ No newline at end of file diff --git a/extend/taobao/domain/BybtInfoDTO.php b/extend/taobao/domain/BybtInfoDTO.php new file mode 100644 index 00000000..98b2f4fd --- /dev/null +++ b/extend/taobao/domain/BybtInfoDTO.php @@ -0,0 +1,50 @@ + \ No newline at end of file diff --git a/extend/taobao/domain/Data.php b/extend/taobao/domain/Data.php new file mode 100644 index 00000000..42182428 --- /dev/null +++ b/extend/taobao/domain/Data.php @@ -0,0 +1,15 @@ + \ No newline at end of file diff --git a/extend/taobao/domain/FavoritesDetail.php b/extend/taobao/domain/FavoritesDetail.php new file mode 100644 index 00000000..e2162f4d --- /dev/null +++ b/extend/taobao/domain/FavoritesDetail.php @@ -0,0 +1,20 @@ + \ No newline at end of file diff --git a/extend/taobao/domain/FavoritesInfo.php b/extend/taobao/domain/FavoritesInfo.php new file mode 100644 index 00000000..1071bb29 --- /dev/null +++ b/extend/taobao/domain/FavoritesInfo.php @@ -0,0 +1,20 @@ + \ No newline at end of file diff --git a/extend/taobao/domain/Feature.php b/extend/taobao/domain/Feature.php new file mode 100644 index 00000000..14031a07 --- /dev/null +++ b/extend/taobao/domain/Feature.php @@ -0,0 +1,20 @@ + \ No newline at end of file diff --git a/extend/taobao/domain/Item.php b/extend/taobao/domain/Item.php new file mode 100644 index 00000000..1b57211f --- /dev/null +++ b/extend/taobao/domain/Item.php @@ -0,0 +1,560 @@ +注:属性名称中的冒号":"被转换为:"#cln#"; 分号";"被转换为:"#scln#") + **/ + public $props_name; + + /** + * 商品资质的信息,用URLEncoder做过转换,使用时,需要URLDecoder转换回来,默认字符集为:UTF-8 + **/ + public $qualification; + + /** + * 商品所属卖家的信用等级数,1表示1心,2表示2心……,只有调用商品搜索:taobao.items.get和taobao.items.search的时候才能返回 + **/ + public $score; + + /** + * 秒杀商品类型。打上秒杀标记的商品,用户只能下架并不能再上架,其他任何编辑或删除操作都不能进行。如果用户想取消秒杀标记,需要联系小二进行操作。如果秒杀结束需要自由编辑请联系活动负责人(小二)去掉秒杀标记。可选类型web_only(只能通过web网络秒杀)wap_only(只能通过wap网络秒杀)web_and_wap(既能通过web秒杀也能通过wap秒杀) + **/ + public $second_kill; + + /** + * 商品卖点信息,天猫商家使用字段,最长150个字符。 + **/ + public $sell_point; + + /** + * 是否承诺退换货服务! + **/ + public $sell_promise; + + /** + * 商品所属的店铺内卖家自定义类目列表 + **/ + public $seller_cids; + + /** + * Sku列表。fields中只设置sku可以返回Sku结构体中所有字段,如果设置为sku.sku_id、sku.properties、sku.quantity等形式就只会返回相应的字段 + **/ + public $skus; + + /** + * 商品销量 + **/ + public $sold_quantity; + + /** + * 手机类目spu 确认信息字段 + **/ + public $spu_confirm; + + /** + * 商品新旧程度(全新:new,闲置:unused,二手:second) + **/ + public $stuff_status; + + /** + * 商品是否支持拍下减库存:1支持;2取消支持(付款减库存);0(默认)不更改 集市卖家默认拍下减库存; 商城卖家默认付款减库存 + **/ + public $sub_stock; + + /** + * 是否支持分期免息 + **/ + public $support_charge_free; + + /** + * 页面模板id + **/ + public $template_id; + + /** + * 商品标题,不能超过60字节 + **/ + public $title; + + /** + * 商品类型(fixed:一口价;auction:拍卖)注:取消团购 + **/ + public $type; + + /** + * 有效期,7或者14(默认是14天) + **/ + public $valid_thru; + + /** + * 商品竖图 + **/ + public $vertical_imgs; + + /** + * 该字段废弃,请勿使用。 + **/ + public $video_id; + + /** + * 商品视频列表(目前只支持单个视频关联)。fields中只设置video可以返回Video结构体中所有字段,如果设置为video.id、video.video_id、video.url等形式就只会返回相应的字段 + **/ + public $videos; + + /** + * 商品是否违规,违规:true , 不违规:false + **/ + public $violation; + + /** + * 商品30天交易量,只有调用商品搜索:taobao.items.get和taobao.items.search的时候才能返回 + **/ + public $volume; + + /** + * 不带html标签的desc文本信息,该字段只在taobao.item.get接口中返回 + **/ + public $wap_desc; + + /** + * 适合wap应用的商品详情url ,该字段只在taobao.item.get接口中返回 + **/ + public $wap_detail_url; + + /** + * 白底图URL + **/ + public $white_bg_image; + + /** + * 无线的宝贝描述 + **/ + public $wireless_desc; + + /** + * 预扣库存,即付款减库存的商品现在有多少处于未付款状态的订单 + **/ + public $with_hold_quantity; + + /** + * 商品所属的商家的旺旺在线状况,taobao.items.search和taobao.items.vip.search专用 + **/ + public $ww_status; +} +?> \ No newline at end of file diff --git a/extend/taobao/domain/ItemImg.php b/extend/taobao/domain/ItemImg.php new file mode 100644 index 00000000..1cf82b91 --- /dev/null +++ b/extend/taobao/domain/ItemImg.php @@ -0,0 +1,30 @@ + \ No newline at end of file diff --git a/extend/taobao/domain/KfcSearchResult.php b/extend/taobao/domain/KfcSearchResult.php new file mode 100644 index 00000000..f8aedbfe --- /dev/null +++ b/extend/taobao/domain/KfcSearchResult.php @@ -0,0 +1,29 @@ + \ No newline at end of file diff --git a/extend/taobao/domain/Location.php b/extend/taobao/domain/Location.php new file mode 100644 index 00000000..c710387c --- /dev/null +++ b/extend/taobao/domain/Location.php @@ -0,0 +1,40 @@ + \ No newline at end of file diff --git a/extend/taobao/domain/MaifanPromotionDTO.php b/extend/taobao/domain/MaifanPromotionDTO.php new file mode 100644 index 00000000..afbf79db --- /dev/null +++ b/extend/taobao/domain/MaifanPromotionDTO.php @@ -0,0 +1,30 @@ + \ No newline at end of file diff --git a/extend/taobao/domain/MapData.php b/extend/taobao/domain/MapData.php new file mode 100644 index 00000000..ac6c0248 --- /dev/null +++ b/extend/taobao/domain/MapData.php @@ -0,0 +1,75 @@ + \ No newline at end of file diff --git a/extend/taobao/domain/NTbkItem.php b/extend/taobao/domain/NTbkItem.php new file mode 100644 index 00000000..03ee01d6 --- /dev/null +++ b/extend/taobao/domain/NTbkItem.php @@ -0,0 +1,220 @@ + \ No newline at end of file diff --git a/extend/taobao/domain/OAuthOtherInfo.php b/extend/taobao/domain/OAuthOtherInfo.php new file mode 100644 index 00000000..0715e57e --- /dev/null +++ b/extend/taobao/domain/OAuthOtherInfo.php @@ -0,0 +1,45 @@ + \ No newline at end of file diff --git a/extend/taobao/domain/OpenAccount.php b/extend/taobao/domain/OpenAccount.php new file mode 100644 index 00000000..ca37db4b --- /dev/null +++ b/extend/taobao/domain/OpenAccount.php @@ -0,0 +1,170 @@ + \ No newline at end of file diff --git a/extend/taobao/domain/OpenAccountResult.php b/extend/taobao/domain/OpenAccountResult.php new file mode 100644 index 00000000..d7563e80 --- /dev/null +++ b/extend/taobao/domain/OpenAccountResult.php @@ -0,0 +1,30 @@ + \ No newline at end of file diff --git a/extend/taobao/domain/OpenAccountSearchResult.php b/extend/taobao/domain/OpenAccountSearchResult.php new file mode 100644 index 00000000..9fe9172d --- /dev/null +++ b/extend/taobao/domain/OpenAccountSearchResult.php @@ -0,0 +1,30 @@ + \ No newline at end of file diff --git a/extend/taobao/domain/OpenAccountTokenApplyResult.php b/extend/taobao/domain/OpenAccountTokenApplyResult.php new file mode 100644 index 00000000..12c9d7e7 --- /dev/null +++ b/extend/taobao/domain/OpenAccountTokenApplyResult.php @@ -0,0 +1,30 @@ + \ No newline at end of file diff --git a/extend/taobao/domain/OpenAccountTokenValidateResult.php b/extend/taobao/domain/OpenAccountTokenValidateResult.php new file mode 100644 index 00000000..86f1989b --- /dev/null +++ b/extend/taobao/domain/OpenAccountTokenValidateResult.php @@ -0,0 +1,30 @@ + \ No newline at end of file diff --git a/extend/taobao/domain/OpenaccountLong.php b/extend/taobao/domain/OpenaccountLong.php new file mode 100644 index 00000000..4f4c4201 --- /dev/null +++ b/extend/taobao/domain/OpenaccountLong.php @@ -0,0 +1,30 @@ + \ No newline at end of file diff --git a/extend/taobao/domain/OpenaccountObject.php b/extend/taobao/domain/OpenaccountObject.php new file mode 100644 index 00000000..4909aa09 --- /dev/null +++ b/extend/taobao/domain/OpenaccountObject.php @@ -0,0 +1,30 @@ + \ No newline at end of file diff --git a/extend/taobao/domain/OpenaccountVoid.php b/extend/taobao/domain/OpenaccountVoid.php new file mode 100644 index 00000000..6580af44 --- /dev/null +++ b/extend/taobao/domain/OpenaccountVoid.php @@ -0,0 +1,25 @@ + \ No newline at end of file diff --git a/extend/taobao/domain/OrderData.php b/extend/taobao/domain/OrderData.php new file mode 100644 index 00000000..f5b04749 --- /dev/null +++ b/extend/taobao/domain/OrderData.php @@ -0,0 +1,30 @@ + \ No newline at end of file diff --git a/extend/taobao/domain/Product.php b/extend/taobao/domain/Product.php new file mode 100644 index 00000000..bd4a6a54 --- /dev/null +++ b/extend/taobao/domain/Product.php @@ -0,0 +1,137 @@ +注:属性名称中的冒号":"被转换为:"#cln#"; +分号";"被转换为:"#scln#" +) + **/ + public $binds_str; + + /** + * 商品类目名称 + **/ + public $cat_name; + + /** + * 商品类目ID.必须是叶子类目ID + **/ + public $cid; + + /** + * 创建时间.格式:yyyy-mm-dd hh:mm:ss + **/ + public $created; + + /** + * 用户自定义属性,结构:pid1:value1;pid2:value2 例如:“20000:优衣库”,表示“品牌:优衣库” + **/ + public $customer_props; + + /** + * 产品的描述.最大25000个字节 + **/ + public $desc; + + /** + * 修改时间.格式:yyyy-mm-dd hh:mm:ss + **/ + public $modified; + + /** + * 产品名称 + **/ + public $name; + + /** + * 外部产品ID + **/ + public $outer_id; + + /** + * 产品的主图片地址.(绝对地址,格式:http://host/image_path) + **/ + public $pic_url; + + /** + * 产品的市场价.单位为元.精确到2位小数;如:200.07 + **/ + public $price; + + /** + * 产品ID + **/ + public $product_id; + + /** + * 产品的子图片.目前最多支持4张。fields中设置为product_imgs.id、product_imgs.url、product_imgs.position 等形式就会返回相应的字段 + **/ + public $product_imgs; + + /** + * 产品的属性图片.比如说黄色对应的产品图片,绿色对应的产品图片。fields中设置为product_prop_imgs.id、 +product_prop_imgs.props、product_prop_imgs.url、product_prop_imgs.position等形式就会返回相应的字段 + **/ + public $product_prop_imgs; + + /** + * 销售属性值别名。格式为pid1:vid1:alias1;pid1:vid2:alia2。 + **/ + public $property_alias; + + /** + * 产品的关键属性列表.格式:pid:vid;pid:vid + **/ + public $props; + + /** + * 产品的关键属性字符串列表.比如:品牌:诺基亚;型号:N73(注:属性名称中的冒号":"被转换为:"#cln#"; +分号";"被转换为:"#scln#" +) + **/ + public $props_str; + + /** + * 产品的销售属性列表.格式:pid:vid;pid:vid + **/ + public $sale_props; + + /** + * 产品的销售属性字符串列表.格式同props_str(注:属性名称中的冒号":"被转换为:"#cln#"; +分号";"被转换为:"#scln#" +) + **/ + public $sale_props_str; + + /** + * 产品卖点描述,长度限制20个汉字 + **/ + public $sell_pt; + + /** + * 当前状态(0 商家确认 1 屏蔽 3 小二确认 2 未确认 -1 删除) + **/ + public $status; + + /** + * 淘宝标准产品编码 + **/ + public $tsc; + + /** + * 垂直市场,如:3(3C),4(鞋城) + **/ + public $vertical_market; +} +?> \ No newline at end of file diff --git a/extend/taobao/domain/ProductImg.php b/extend/taobao/domain/ProductImg.php new file mode 100644 index 00000000..7c9de672 --- /dev/null +++ b/extend/taobao/domain/ProductImg.php @@ -0,0 +1,40 @@ + \ No newline at end of file diff --git a/extend/taobao/domain/ProductPropImg.php b/extend/taobao/domain/ProductPropImg.php new file mode 100644 index 00000000..1086978d --- /dev/null +++ b/extend/taobao/domain/ProductPropImg.php @@ -0,0 +1,46 @@ + \ No newline at end of file diff --git a/extend/taobao/domain/PromotionExtend.php b/extend/taobao/domain/PromotionExtend.php new file mode 100644 index 00000000..1e96064a --- /dev/null +++ b/extend/taobao/domain/PromotionExtend.php @@ -0,0 +1,25 @@ + \ No newline at end of file diff --git a/extend/taobao/domain/PromotionList.php b/extend/taobao/domain/PromotionList.php new file mode 100644 index 00000000..dc532109 --- /dev/null +++ b/extend/taobao/domain/PromotionList.php @@ -0,0 +1,30 @@ + \ No newline at end of file diff --git a/extend/taobao/domain/PropImg.php b/extend/taobao/domain/PropImg.php new file mode 100644 index 00000000..baadb2c4 --- /dev/null +++ b/extend/taobao/domain/PropImg.php @@ -0,0 +1,35 @@ + \ No newline at end of file diff --git a/extend/taobao/domain/PropValue.php b/extend/taobao/domain/PropValue.php new file mode 100644 index 00000000..15c7186e --- /dev/null +++ b/extend/taobao/domain/PropValue.php @@ -0,0 +1,60 @@ + \ No newline at end of file diff --git a/extend/taobao/domain/RecommendItemList.php b/extend/taobao/domain/RecommendItemList.php new file mode 100644 index 00000000..3338a68a --- /dev/null +++ b/extend/taobao/domain/RecommendItemList.php @@ -0,0 +1,20 @@ + \ No newline at end of file diff --git a/extend/taobao/domain/Results.php b/extend/taobao/domain/Results.php new file mode 100644 index 00000000..1f31bfe9 --- /dev/null +++ b/extend/taobao/domain/Results.php @@ -0,0 +1,15 @@ + \ No newline at end of file diff --git a/extend/taobao/domain/Sku.php b/extend/taobao/domain/Sku.php new file mode 100644 index 00000000..d76fd6b5 --- /dev/null +++ b/extend/taobao/domain/Sku.php @@ -0,0 +1,120 @@ + \ No newline at end of file diff --git a/extend/taobao/domain/SpCampaign.php b/extend/taobao/domain/SpCampaign.php new file mode 100644 index 00000000..b27afeec --- /dev/null +++ b/extend/taobao/domain/SpCampaign.php @@ -0,0 +1,40 @@ + \ No newline at end of file diff --git a/extend/taobao/domain/TokenInfo.php b/extend/taobao/domain/TokenInfo.php new file mode 100644 index 00000000..e2e71989 --- /dev/null +++ b/extend/taobao/domain/TokenInfo.php @@ -0,0 +1,40 @@ + \ No newline at end of file diff --git a/extend/taobao/domain/TokenInfoExt.php b/extend/taobao/domain/TokenInfoExt.php new file mode 100644 index 00000000..052152f7 --- /dev/null +++ b/extend/taobao/domain/TokenInfoExt.php @@ -0,0 +1,20 @@ + \ No newline at end of file diff --git a/extend/taobao/domain/TopDownloadRecordDo.php b/extend/taobao/domain/TopDownloadRecordDo.php new file mode 100644 index 00000000..fc616220 --- /dev/null +++ b/extend/taobao/domain/TopDownloadRecordDo.php @@ -0,0 +1,25 @@ + \ No newline at end of file diff --git a/extend/taobao/domain/TopNInfoDTO.php b/extend/taobao/domain/TopNInfoDTO.php new file mode 100644 index 00000000..12ccc816 --- /dev/null +++ b/extend/taobao/domain/TopNInfoDTO.php @@ -0,0 +1,35 @@ + \ No newline at end of file diff --git a/extend/taobao/domain/TradeConfirmFee.php b/extend/taobao/domain/TradeConfirmFee.php new file mode 100644 index 00000000..5517b5d2 --- /dev/null +++ b/extend/taobao/domain/TradeConfirmFee.php @@ -0,0 +1,25 @@ + \ No newline at end of file diff --git a/extend/taobao/domain/Video.php b/extend/taobao/domain/Video.php new file mode 100644 index 00000000..b6b258dc --- /dev/null +++ b/extend/taobao/domain/Video.php @@ -0,0 +1,45 @@ + \ No newline at end of file diff --git a/extend/taobao/domain/WordMapData.php b/extend/taobao/domain/WordMapData.php new file mode 100644 index 00000000..f3cb94eb --- /dev/null +++ b/extend/taobao/domain/WordMapData.php @@ -0,0 +1,20 @@ + \ No newline at end of file diff --git a/extend/taobao/domain/Youjiacouponinfo.php b/extend/taobao/domain/Youjiacouponinfo.php new file mode 100644 index 00000000..a02fc847 --- /dev/null +++ b/extend/taobao/domain/Youjiacouponinfo.php @@ -0,0 +1,20 @@ + \ No newline at end of file diff --git a/extend/taobao/request/AppipGetRequest.php b/extend/taobao/request/AppipGetRequest.php new file mode 100644 index 00000000..914de137 --- /dev/null +++ b/extend/taobao/request/AppipGetRequest.php @@ -0,0 +1,32 @@ +apiParas; + } + + public function check() + { + + } + + public function putOtherTextParam($key, $value) { + $this->apiParas[$key] = $value; + $this->$key = $value; + } +} diff --git a/extend/taobao/request/AreasGetRequest.php b/extend/taobao/request/AreasGetRequest.php new file mode 100644 index 00000000..04b9d183 --- /dev/null +++ b/extend/taobao/request/AreasGetRequest.php @@ -0,0 +1,48 @@ +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/extend/taobao/request/BaichuanOpenaccountLoginRequest.php b/extend/taobao/request/BaichuanOpenaccountLoginRequest.php new file mode 100644 index 00000000..f6b7e6e9 --- /dev/null +++ b/extend/taobao/request/BaichuanOpenaccountLoginRequest.php @@ -0,0 +1,47 @@ +name = $name; + $this->apiParas["name"] = $name; + } + + public function getName() + { + return $this->name; + } + + public function getApiMethodName() + { + return "taobao.baichuan.openaccount.login"; + } + + public function getApiParas() + { + return $this->apiParas; + } + + public function check() + { + + } + + public function putOtherTextParam($key, $value) { + $this->apiParas[$key] = $value; + $this->$key = $value; + } +} diff --git a/extend/taobao/request/BaichuanOpenaccountLoginbytokenRequest.php b/extend/taobao/request/BaichuanOpenaccountLoginbytokenRequest.php new file mode 100644 index 00000000..753c1d7a --- /dev/null +++ b/extend/taobao/request/BaichuanOpenaccountLoginbytokenRequest.php @@ -0,0 +1,47 @@ +name = $name; + $this->apiParas["name"] = $name; + } + + public function getName() + { + return $this->name; + } + + public function getApiMethodName() + { + return "taobao.baichuan.openaccount.loginbytoken"; + } + + public function getApiParas() + { + return $this->apiParas; + } + + public function check() + { + + } + + public function putOtherTextParam($key, $value) { + $this->apiParas[$key] = $value; + $this->$key = $value; + } +} diff --git a/extend/taobao/request/BaichuanOpenaccountLogindoublecheckRequest.php b/extend/taobao/request/BaichuanOpenaccountLogindoublecheckRequest.php new file mode 100644 index 00000000..c4213c3d --- /dev/null +++ b/extend/taobao/request/BaichuanOpenaccountLogindoublecheckRequest.php @@ -0,0 +1,47 @@ +name = $name; + $this->apiParas["name"] = $name; + } + + public function getName() + { + return $this->name; + } + + public function getApiMethodName() + { + return "taobao.baichuan.openaccount.logindoublecheck"; + } + + public function getApiParas() + { + return $this->apiParas; + } + + public function check() + { + + } + + public function putOtherTextParam($key, $value) { + $this->apiParas[$key] = $value; + $this->$key = $value; + } +} diff --git a/extend/taobao/request/BaichuanOpenaccountNewlogindoublecheckRequest.php b/extend/taobao/request/BaichuanOpenaccountNewlogindoublecheckRequest.php new file mode 100644 index 00000000..f48bc919 --- /dev/null +++ b/extend/taobao/request/BaichuanOpenaccountNewlogindoublecheckRequest.php @@ -0,0 +1,47 @@ +name = $name; + $this->apiParas["name"] = $name; + } + + public function getName() + { + return $this->name; + } + + public function getApiMethodName() + { + return "taobao.baichuan.openaccount.newlogindoublecheck"; + } + + public function getApiParas() + { + return $this->apiParas; + } + + public function check() + { + + } + + public function putOtherTextParam($key, $value) { + $this->apiParas[$key] = $value; + $this->$key = $value; + } +} diff --git a/extend/taobao/request/BaichuanOpenaccountPasswordResetRequest.php b/extend/taobao/request/BaichuanOpenaccountPasswordResetRequest.php new file mode 100644 index 00000000..03827c60 --- /dev/null +++ b/extend/taobao/request/BaichuanOpenaccountPasswordResetRequest.php @@ -0,0 +1,47 @@ +name = $name; + $this->apiParas["name"] = $name; + } + + public function getName() + { + return $this->name; + } + + public function getApiMethodName() + { + return "taobao.baichuan.openaccount.password.reset"; + } + + public function getApiParas() + { + return $this->apiParas; + } + + public function check() + { + + } + + public function putOtherTextParam($key, $value) { + $this->apiParas[$key] = $value; + $this->$key = $value; + } +} diff --git a/extend/taobao/request/BaichuanOpenaccountRegisterRequest.php b/extend/taobao/request/BaichuanOpenaccountRegisterRequest.php new file mode 100644 index 00000000..ec2a907e --- /dev/null +++ b/extend/taobao/request/BaichuanOpenaccountRegisterRequest.php @@ -0,0 +1,47 @@ +name = $name; + $this->apiParas["name"] = $name; + } + + public function getName() + { + return $this->name; + } + + public function getApiMethodName() + { + return "taobao.baichuan.openaccount.register"; + } + + public function getApiParas() + { + return $this->apiParas; + } + + public function check() + { + + } + + public function putOtherTextParam($key, $value) { + $this->apiParas[$key] = $value; + $this->$key = $value; + } +} diff --git a/extend/taobao/request/BaichuanOpenaccountRegistercodeCheckRequest.php b/extend/taobao/request/BaichuanOpenaccountRegistercodeCheckRequest.php new file mode 100644 index 00000000..6c2c2809 --- /dev/null +++ b/extend/taobao/request/BaichuanOpenaccountRegistercodeCheckRequest.php @@ -0,0 +1,47 @@ +name = $name; + $this->apiParas["name"] = $name; + } + + public function getName() + { + return $this->name; + } + + public function getApiMethodName() + { + return "taobao.baichuan.openaccount.registercode.check"; + } + + public function getApiParas() + { + return $this->apiParas; + } + + public function check() + { + + } + + public function putOtherTextParam($key, $value) { + $this->apiParas[$key] = $value; + $this->$key = $value; + } +} diff --git a/extend/taobao/request/BaichuanOpenaccountRegistercodeSendRequest.php b/extend/taobao/request/BaichuanOpenaccountRegistercodeSendRequest.php new file mode 100644 index 00000000..9424c02f --- /dev/null +++ b/extend/taobao/request/BaichuanOpenaccountRegistercodeSendRequest.php @@ -0,0 +1,47 @@ +name = $name; + $this->apiParas["name"] = $name; + } + + public function getName() + { + return $this->name; + } + + public function getApiMethodName() + { + return "taobao.baichuan.openaccount.registercode.send"; + } + + public function getApiParas() + { + return $this->apiParas; + } + + public function check() + { + + } + + public function putOtherTextParam($key, $value) { + $this->apiParas[$key] = $value; + $this->$key = $value; + } +} diff --git a/extend/taobao/request/BaichuanOpenaccountResetcodeCheckRequest.php b/extend/taobao/request/BaichuanOpenaccountResetcodeCheckRequest.php new file mode 100644 index 00000000..24c6cf5a --- /dev/null +++ b/extend/taobao/request/BaichuanOpenaccountResetcodeCheckRequest.php @@ -0,0 +1,47 @@ +name = $name; + $this->apiParas["name"] = $name; + } + + public function getName() + { + return $this->name; + } + + public function getApiMethodName() + { + return "taobao.baichuan.openaccount.resetcode.check"; + } + + public function getApiParas() + { + return $this->apiParas; + } + + public function check() + { + + } + + public function putOtherTextParam($key, $value) { + $this->apiParas[$key] = $value; + $this->$key = $value; + } +} diff --git a/extend/taobao/request/BaichuanOpenaccountResetcodeSendRequest.php b/extend/taobao/request/BaichuanOpenaccountResetcodeSendRequest.php new file mode 100644 index 00000000..f591174a --- /dev/null +++ b/extend/taobao/request/BaichuanOpenaccountResetcodeSendRequest.php @@ -0,0 +1,47 @@ +name = $name; + $this->apiParas["name"] = $name; + } + + public function getName() + { + return $this->name; + } + + public function getApiMethodName() + { + return "taobao.baichuan.openaccount.resetcode.send"; + } + + public function getApiParas() + { + return $this->apiParas; + } + + public function check() + { + + } + + public function putOtherTextParam($key, $value) { + $this->apiParas[$key] = $value; + $this->$key = $value; + } +} diff --git a/extend/taobao/request/BaichuanOrderurlGetRequest.php b/extend/taobao/request/BaichuanOrderurlGetRequest.php new file mode 100644 index 00000000..851fc7d9 --- /dev/null +++ b/extend/taobao/request/BaichuanOrderurlGetRequest.php @@ -0,0 +1,47 @@ +name = $name; + $this->apiParas["name"] = $name; + } + + public function getName() + { + return $this->name; + } + + public function getApiMethodName() + { + return "taobao.baichuan.orderurl.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/extend/taobao/request/BaichuanPayresultQueryRequest.php b/extend/taobao/request/BaichuanPayresultQueryRequest.php new file mode 100644 index 00000000..a4157b1a --- /dev/null +++ b/extend/taobao/request/BaichuanPayresultQueryRequest.php @@ -0,0 +1,47 @@ +name = $name; + $this->apiParas["name"] = $name; + } + + public function getName() + { + return $this->name; + } + + public function getApiMethodName() + { + return "taobao.baichuan.payresult.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/extend/taobao/request/BaichuanTaokeTraceRequest.php b/extend/taobao/request/BaichuanTaokeTraceRequest.php new file mode 100644 index 00000000..e71d4d94 --- /dev/null +++ b/extend/taobao/request/BaichuanTaokeTraceRequest.php @@ -0,0 +1,47 @@ +name = $name; + $this->apiParas["name"] = $name; + } + + public function getName() + { + return $this->name; + } + + public function getApiMethodName() + { + return "taobao.baichuan.taoke.trace"; + } + + public function getApiParas() + { + return $this->apiParas; + } + + public function check() + { + + } + + public function putOtherTextParam($key, $value) { + $this->apiParas[$key] = $value; + $this->$key = $value; + } +} diff --git a/extend/taobao/request/BaichuanUserLoginRequest.php b/extend/taobao/request/BaichuanUserLoginRequest.php new file mode 100644 index 00000000..04bf5872 --- /dev/null +++ b/extend/taobao/request/BaichuanUserLoginRequest.php @@ -0,0 +1,47 @@ +name = $name; + $this->apiParas["name"] = $name; + } + + public function getName() + { + return $this->name; + } + + public function getApiMethodName() + { + return "taobao.baichuan.user.login"; + } + + public function getApiParas() + { + return $this->apiParas; + } + + public function check() + { + + } + + public function putOtherTextParam($key, $value) { + $this->apiParas[$key] = $value; + $this->$key = $value; + } +} diff --git a/extend/taobao/request/BaichuanUserLoginbytokenRequest.php b/extend/taobao/request/BaichuanUserLoginbytokenRequest.php new file mode 100644 index 00000000..e05a4fe4 --- /dev/null +++ b/extend/taobao/request/BaichuanUserLoginbytokenRequest.php @@ -0,0 +1,47 @@ +name = $name; + $this->apiParas["name"] = $name; + } + + public function getName() + { + return $this->name; + } + + public function getApiMethodName() + { + return "taobao.baichuan.user.loginbytoken"; + } + + public function getApiParas() + { + return $this->apiParas; + } + + public function check() + { + + } + + public function putOtherTextParam($key, $value) { + $this->apiParas[$key] = $value; + $this->$key = $value; + } +} diff --git a/extend/taobao/request/BaichuanUserLogindoublecheckRequest.php b/extend/taobao/request/BaichuanUserLogindoublecheckRequest.php new file mode 100644 index 00000000..76a7d54e --- /dev/null +++ b/extend/taobao/request/BaichuanUserLogindoublecheckRequest.php @@ -0,0 +1,47 @@ +name = $name; + $this->apiParas["name"] = $name; + } + + public function getName() + { + return $this->name; + } + + public function getApiMethodName() + { + return "taobao.baichuan.user.logindoublecheck"; + } + + public function getApiParas() + { + return $this->apiParas; + } + + public function check() + { + + } + + public function putOtherTextParam($key, $value) { + $this->apiParas[$key] = $value; + $this->$key = $value; + } +} diff --git a/extend/taobao/request/CloudpushMessageAndroidRequest.php b/extend/taobao/request/CloudpushMessageAndroidRequest.php new file mode 100644 index 00000000..958f966e --- /dev/null +++ b/extend/taobao/request/CloudpushMessageAndroidRequest.php @@ -0,0 +1,82 @@ +body = $body; + $this->apiParas["body"] = $body; + } + + public function getBody() + { + return $this->body; + } + + public function setTarget($target) + { + $this->target = $target; + $this->apiParas["target"] = $target; + } + + public function getTarget() + { + return $this->target; + } + + public function setTargetValue($targetValue) + { + $this->targetValue = $targetValue; + $this->apiParas["target_value"] = $targetValue; + } + + public function getTargetValue() + { + return $this->targetValue; + } + + public function getApiMethodName() + { + return "taobao.cloudpush.message.android"; + } + + public function getApiParas() + { + return $this->apiParas; + } + + public function check() + { + + RequestCheckUtil::checkNotNull($this->body,"body"); + RequestCheckUtil::checkNotNull($this->target,"target"); + RequestCheckUtil::checkNotNull($this->targetValue,"targetValue"); + } + + public function putOtherTextParam($key, $value) { + $this->apiParas[$key] = $value; + $this->$key = $value; + } +} diff --git a/extend/taobao/request/CloudpushMessageIosRequest.php b/extend/taobao/request/CloudpushMessageIosRequest.php new file mode 100644 index 00000000..06f45b67 --- /dev/null +++ b/extend/taobao/request/CloudpushMessageIosRequest.php @@ -0,0 +1,82 @@ +body = $body; + $this->apiParas["body"] = $body; + } + + public function getBody() + { + return $this->body; + } + + public function setTarget($target) + { + $this->target = $target; + $this->apiParas["target"] = $target; + } + + public function getTarget() + { + return $this->target; + } + + public function setTargetValue($targetValue) + { + $this->targetValue = $targetValue; + $this->apiParas["target_value"] = $targetValue; + } + + public function getTargetValue() + { + return $this->targetValue; + } + + public function getApiMethodName() + { + return "taobao.cloudpush.message.ios"; + } + + public function getApiParas() + { + return $this->apiParas; + } + + public function check() + { + + RequestCheckUtil::checkNotNull($this->body,"body"); + RequestCheckUtil::checkNotNull($this->target,"target"); + RequestCheckUtil::checkNotNull($this->targetValue,"targetValue"); + } + + public function putOtherTextParam($key, $value) { + $this->apiParas[$key] = $value; + $this->$key = $value; + } +} diff --git a/extend/taobao/request/CloudpushNoticeAndroidRequest.php b/extend/taobao/request/CloudpushNoticeAndroidRequest.php new file mode 100644 index 00000000..b161b773 --- /dev/null +++ b/extend/taobao/request/CloudpushNoticeAndroidRequest.php @@ -0,0 +1,99 @@ +summary = $summary; + $this->apiParas["summary"] = $summary; + } + + public function getSummary() + { + return $this->summary; + } + + public function setTarget($target) + { + $this->target = $target; + $this->apiParas["target"] = $target; + } + + public function getTarget() + { + return $this->target; + } + + public function setTargetValue($targetValue) + { + $this->targetValue = $targetValue; + $this->apiParas["target_value"] = $targetValue; + } + + public function getTargetValue() + { + return $this->targetValue; + } + + public function setTitle($title) + { + $this->title = $title; + $this->apiParas["title"] = $title; + } + + public function getTitle() + { + return $this->title; + } + + public function getApiMethodName() + { + return "taobao.cloudpush.notice.android"; + } + + public function getApiParas() + { + return $this->apiParas; + } + + public function check() + { + + RequestCheckUtil::checkNotNull($this->summary,"summary"); + RequestCheckUtil::checkNotNull($this->target,"target"); + RequestCheckUtil::checkNotNull($this->targetValue,"targetValue"); + RequestCheckUtil::checkNotNull($this->title,"title"); + } + + public function putOtherTextParam($key, $value) { + $this->apiParas[$key] = $value; + $this->$key = $value; + } +} diff --git a/extend/taobao/request/CloudpushNoticeIosRequest.php b/extend/taobao/request/CloudpushNoticeIosRequest.php new file mode 100644 index 00000000..1ec20b89 --- /dev/null +++ b/extend/taobao/request/CloudpushNoticeIosRequest.php @@ -0,0 +1,115 @@ +env = $env; + $this->apiParas["env"] = $env; + } + + public function getEnv() + { + return $this->env; + } + + public function setExt($ext) + { + $this->ext = $ext; + $this->apiParas["ext"] = $ext; + } + + public function getExt() + { + return $this->ext; + } + + public function setSummary($summary) + { + $this->summary = $summary; + $this->apiParas["summary"] = $summary; + } + + public function getSummary() + { + return $this->summary; + } + + public function setTarget($target) + { + $this->target = $target; + $this->apiParas["target"] = $target; + } + + public function getTarget() + { + return $this->target; + } + + public function setTargetValue($targetValue) + { + $this->targetValue = $targetValue; + $this->apiParas["target_value"] = $targetValue; + } + + public function getTargetValue() + { + return $this->targetValue; + } + + public function getApiMethodName() + { + return "taobao.cloudpush.notice.ios"; + } + + public function getApiParas() + { + return $this->apiParas; + } + + public function check() + { + + RequestCheckUtil::checkNotNull($this->env,"env"); + RequestCheckUtil::checkNotNull($this->summary,"summary"); + RequestCheckUtil::checkNotNull($this->target,"target"); + RequestCheckUtil::checkNotNull($this->targetValue,"targetValue"); + } + + public function putOtherTextParam($key, $value) { + $this->apiParas[$key] = $value; + $this->$key = $value; + } +} diff --git a/extend/taobao/request/CloudpushPushRequest.php b/extend/taobao/request/CloudpushPushRequest.php new file mode 100644 index 00000000..cd2d8113 --- /dev/null +++ b/extend/taobao/request/CloudpushPushRequest.php @@ -0,0 +1,374 @@ +androidActivity = $androidActivity; + $this->apiParas["android_activity"] = $androidActivity; + } + + public function getAndroidActivity() + { + return $this->androidActivity; + } + + public function setAndroidExtParameters($androidExtParameters) + { + $this->androidExtParameters = $androidExtParameters; + $this->apiParas["android_ext_parameters"] = $androidExtParameters; + } + + public function getAndroidExtParameters() + { + return $this->androidExtParameters; + } + + public function setAndroidMusic($androidMusic) + { + $this->androidMusic = $androidMusic; + $this->apiParas["android_music"] = $androidMusic; + } + + public function getAndroidMusic() + { + return $this->androidMusic; + } + + public function setAndroidOpenType($androidOpenType) + { + $this->androidOpenType = $androidOpenType; + $this->apiParas["android_open_type"] = $androidOpenType; + } + + public function getAndroidOpenType() + { + return $this->androidOpenType; + } + + public function setAndroidOpenUrl($androidOpenUrl) + { + $this->androidOpenUrl = $androidOpenUrl; + $this->apiParas["android_open_url"] = $androidOpenUrl; + } + + public function getAndroidOpenUrl() + { + return $this->androidOpenUrl; + } + + public function setAntiHarassDuration($antiHarassDuration) + { + $this->antiHarassDuration = $antiHarassDuration; + $this->apiParas["anti_harass_duration"] = $antiHarassDuration; + } + + public function getAntiHarassDuration() + { + return $this->antiHarassDuration; + } + + public function setAntiHarassStartTime($antiHarassStartTime) + { + $this->antiHarassStartTime = $antiHarassStartTime; + $this->apiParas["anti_harass_start_time"] = $antiHarassStartTime; + } + + public function getAntiHarassStartTime() + { + return $this->antiHarassStartTime; + } + + public function setBatchNumber($batchNumber) + { + $this->batchNumber = $batchNumber; + $this->apiParas["batch_number"] = $batchNumber; + } + + public function getBatchNumber() + { + return $this->batchNumber; + } + + public function setBody($body) + { + $this->body = $body; + $this->apiParas["body"] = $body; + } + + public function getBody() + { + return $this->body; + } + + public function setDeviceType($deviceType) + { + $this->deviceType = $deviceType; + $this->apiParas["device_type"] = $deviceType; + } + + public function getDeviceType() + { + return $this->deviceType; + } + + public function setIosBadge($iosBadge) + { + $this->iosBadge = $iosBadge; + $this->apiParas["ios_badge"] = $iosBadge; + } + + public function getIosBadge() + { + return $this->iosBadge; + } + + public function setIosExtParameters($iosExtParameters) + { + $this->iosExtParameters = $iosExtParameters; + $this->apiParas["ios_ext_parameters"] = $iosExtParameters; + } + + public function getIosExtParameters() + { + return $this->iosExtParameters; + } + + public function setIosMusic($iosMusic) + { + $this->iosMusic = $iosMusic; + $this->apiParas["ios_music"] = $iosMusic; + } + + public function getIosMusic() + { + return $this->iosMusic; + } + + public function setRemind($remind) + { + $this->remind = $remind; + $this->apiParas["remind"] = $remind; + } + + public function getRemind() + { + return $this->remind; + } + + public function setStoreOffline($storeOffline) + { + $this->storeOffline = $storeOffline; + $this->apiParas["store_offline"] = $storeOffline; + } + + public function getStoreOffline() + { + return $this->storeOffline; + } + + public function setSummery($summery) + { + $this->summery = $summery; + $this->apiParas["summery"] = $summery; + } + + public function getSummery() + { + return $this->summery; + } + + public function setTarget($target) + { + $this->target = $target; + $this->apiParas["target"] = $target; + } + + public function getTarget() + { + return $this->target; + } + + public function setTargetValue($targetValue) + { + $this->targetValue = $targetValue; + $this->apiParas["target_value"] = $targetValue; + } + + public function getTargetValue() + { + return $this->targetValue; + } + + public function setTimeout($timeout) + { + $this->timeout = $timeout; + $this->apiParas["timeout"] = $timeout; + } + + public function getTimeout() + { + return $this->timeout; + } + + public function setTitle($title) + { + $this->title = $title; + $this->apiParas["title"] = $title; + } + + public function getTitle() + { + return $this->title; + } + + public function setType($type) + { + $this->type = $type; + $this->apiParas["type"] = $type; + } + + public function getType() + { + return $this->type; + } + + public function getApiMethodName() + { + return "taobao.cloudpush.push"; + } + + public function getApiParas() + { + return $this->apiParas; + } + + public function check() + { + + RequestCheckUtil::checkNotNull($this->body,"body"); + RequestCheckUtil::checkNotNull($this->deviceType,"deviceType"); + RequestCheckUtil::checkNotNull($this->remind,"remind"); + RequestCheckUtil::checkNotNull($this->storeOffline,"storeOffline"); + RequestCheckUtil::checkNotNull($this->target,"target"); + RequestCheckUtil::checkNotNull($this->targetValue,"targetValue"); + RequestCheckUtil::checkNotNull($this->title,"title"); + } + + public function putOtherTextParam($key, $value) { + $this->apiParas[$key] = $value; + $this->$key = $value; + } +} diff --git a/extend/taobao/request/FilesGetRequest.php b/extend/taobao/request/FilesGetRequest.php new file mode 100644 index 00000000..01aee8cb --- /dev/null +++ b/extend/taobao/request/FilesGetRequest.php @@ -0,0 +1,81 @@ +endDate = $endDate; + $this->apiParas["end_date"] = $endDate; + } + + public function getEndDate() + { + return $this->endDate; + } + + public function setStartDate($startDate) + { + $this->startDate = $startDate; + $this->apiParas["start_date"] = $startDate; + } + + public function getStartDate() + { + return $this->startDate; + } + + public function setStatus($status) + { + $this->status = $status; + $this->apiParas["status"] = $status; + } + + public function getStatus() + { + return $this->status; + } + + public function getApiMethodName() + { + return "taobao.files.get"; + } + + public function getApiParas() + { + return $this->apiParas; + } + + public function check() + { + + RequestCheckUtil::checkNotNull($this->endDate,"endDate"); + RequestCheckUtil::checkNotNull($this->startDate,"startDate"); + } + + public function putOtherTextParam($key, $value) { + $this->apiParas[$key] = $value; + $this->$key = $value; + } +} diff --git a/extend/taobao/request/HttpdnsGetRequest.php b/extend/taobao/request/HttpdnsGetRequest.php new file mode 100644 index 00000000..cd57ad5f --- /dev/null +++ b/extend/taobao/request/HttpdnsGetRequest.php @@ -0,0 +1,32 @@ +apiParas; + } + + public function check() + { + + } + + public function putOtherTextParam($key, $value) { + $this->apiParas[$key] = $value; + $this->$key = $value; + } +} diff --git a/extend/taobao/request/ItemImgDeleteRequest.php b/extend/taobao/request/ItemImgDeleteRequest.php new file mode 100644 index 00000000..291535f8 --- /dev/null +++ b/extend/taobao/request/ItemImgDeleteRequest.php @@ -0,0 +1,81 @@ +id = $id; + $this->apiParas["id"] = $id; + } + + public function getId() + { + return $this->id; + } + + public function setIsSixthPic($isSixthPic) + { + $this->isSixthPic = $isSixthPic; + $this->apiParas["is_sixth_pic"] = $isSixthPic; + } + + public function getIsSixthPic() + { + return $this->isSixthPic; + } + + public function setNumIid($numIid) + { + $this->numIid = $numIid; + $this->apiParas["num_iid"] = $numIid; + } + + public function getNumIid() + { + return $this->numIid; + } + + public function getApiMethodName() + { + return "taobao.item.img.delete"; + } + + public function getApiParas() + { + return $this->apiParas; + } + + public function check() + { + + RequestCheckUtil::checkNotNull($this->id,"id"); + RequestCheckUtil::checkNotNull($this->numIid,"numIid"); + } + + public function putOtherTextParam($key, $value) { + $this->apiParas[$key] = $value; + $this->$key = $value; + } +} diff --git a/extend/taobao/request/ItemImgUploadRequest.php b/extend/taobao/request/ItemImgUploadRequest.php new file mode 100644 index 00000000..efa0b66a --- /dev/null +++ b/extend/taobao/request/ItemImgUploadRequest.php @@ -0,0 +1,128 @@ +id = $id; + $this->apiParas["id"] = $id; + } + + public function getId() + { + return $this->id; + } + + public function setImage($image) + { + $this->image = $image; + $this->apiParas["image"] = $image; + } + + public function getImage() + { + return $this->image; + } + + public function setIsMajor($isMajor) + { + $this->isMajor = $isMajor; + $this->apiParas["is_major"] = $isMajor; + } + + public function getIsMajor() + { + return $this->isMajor; + } + + public function setIsRectangle($isRectangle) + { + $this->isRectangle = $isRectangle; + $this->apiParas["is_rectangle"] = $isRectangle; + } + + public function getIsRectangle() + { + return $this->isRectangle; + } + + public function setNumIid($numIid) + { + $this->numIid = $numIid; + $this->apiParas["num_iid"] = $numIid; + } + + public function getNumIid() + { + return $this->numIid; + } + + public function setPosition($position) + { + $this->position = $position; + $this->apiParas["position"] = $position; + } + + public function getPosition() + { + return $this->position; + } + + public function getApiMethodName() + { + return "taobao.item.img.upload"; + } + + public function getApiParas() + { + return $this->apiParas; + } + + public function check() + { + + RequestCheckUtil::checkNotNull($this->numIid,"numIid"); + } + + public function putOtherTextParam($key, $value) { + $this->apiParas[$key] = $value; + $this->$key = $value; + } +} diff --git a/extend/taobao/request/ItemJointImgRequest.php b/extend/taobao/request/ItemJointImgRequest.php new file mode 100644 index 00000000..81ee6eb7 --- /dev/null +++ b/extend/taobao/request/ItemJointImgRequest.php @@ -0,0 +1,129 @@ +id = $id; + $this->apiParas["id"] = $id; + } + + public function getId() + { + return $this->id; + } + + public function setIsMajor($isMajor) + { + $this->isMajor = $isMajor; + $this->apiParas["is_major"] = $isMajor; + } + + public function getIsMajor() + { + return $this->isMajor; + } + + public function setIsRectangle($isRectangle) + { + $this->isRectangle = $isRectangle; + $this->apiParas["is_rectangle"] = $isRectangle; + } + + public function getIsRectangle() + { + return $this->isRectangle; + } + + public function setNumIid($numIid) + { + $this->numIid = $numIid; + $this->apiParas["num_iid"] = $numIid; + } + + public function getNumIid() + { + return $this->numIid; + } + + public function setPicPath($picPath) + { + $this->picPath = $picPath; + $this->apiParas["pic_path"] = $picPath; + } + + public function getPicPath() + { + return $this->picPath; + } + + public function setPosition($position) + { + $this->position = $position; + $this->apiParas["position"] = $position; + } + + public function getPosition() + { + return $this->position; + } + + public function getApiMethodName() + { + return "taobao.item.joint.img"; + } + + public function getApiParas() + { + return $this->apiParas; + } + + public function check() + { + + RequestCheckUtil::checkNotNull($this->numIid,"numIid"); + RequestCheckUtil::checkNotNull($this->picPath,"picPath"); + } + + public function putOtherTextParam($key, $value) { + $this->apiParas[$key] = $value; + $this->$key = $value; + } +} diff --git a/extend/taobao/request/ItemJointPropimgRequest.php b/extend/taobao/request/ItemJointPropimgRequest.php new file mode 100644 index 00000000..7b88ef8c --- /dev/null +++ b/extend/taobao/request/ItemJointPropimgRequest.php @@ -0,0 +1,114 @@ +id = $id; + $this->apiParas["id"] = $id; + } + + public function getId() + { + return $this->id; + } + + public function setNumIid($numIid) + { + $this->numIid = $numIid; + $this->apiParas["num_iid"] = $numIid; + } + + public function getNumIid() + { + return $this->numIid; + } + + public function setPicPath($picPath) + { + $this->picPath = $picPath; + $this->apiParas["pic_path"] = $picPath; + } + + public function getPicPath() + { + return $this->picPath; + } + + public function setPosition($position) + { + $this->position = $position; + $this->apiParas["position"] = $position; + } + + public function getPosition() + { + return $this->position; + } + + public function setProperties($properties) + { + $this->properties = $properties; + $this->apiParas["properties"] = $properties; + } + + public function getProperties() + { + return $this->properties; + } + + public function getApiMethodName() + { + return "taobao.item.joint.propimg"; + } + + public function getApiParas() + { + return $this->apiParas; + } + + public function check() + { + + RequestCheckUtil::checkNotNull($this->numIid,"numIid"); + RequestCheckUtil::checkNotNull($this->picPath,"picPath"); + RequestCheckUtil::checkNotNull($this->properties,"properties"); + } + + public function putOtherTextParam($key, $value) { + $this->apiParas[$key] = $value; + $this->$key = $value; + } +} diff --git a/extend/taobao/request/ItemSkusGetRequest.php b/extend/taobao/request/ItemSkusGetRequest.php new file mode 100644 index 00000000..e8e53a2d --- /dev/null +++ b/extend/taobao/request/ItemSkusGetRequest.php @@ -0,0 +1,66 @@ +fields = $fields; + $this->apiParas["fields"] = $fields; + } + + public function getFields() + { + return $this->fields; + } + + public function setNumIids($numIids) + { + $this->numIids = $numIids; + $this->apiParas["num_iids"] = $numIids; + } + + public function getNumIids() + { + return $this->numIids; + } + + public function getApiMethodName() + { + return "taobao.item.skus.get"; + } + + public function getApiParas() + { + return $this->apiParas; + } + + public function check() + { + + RequestCheckUtil::checkNotNull($this->fields,"fields"); + RequestCheckUtil::checkMaxListSize($this->fields,20,"fields"); + RequestCheckUtil::checkNotNull($this->numIids,"numIids"); + } + + public function putOtherTextParam($key, $value) { + $this->apiParas[$key] = $value; + $this->$key = $value; + } +} diff --git a/extend/taobao/request/ItemUpdateDelistingRequest.php b/extend/taobao/request/ItemUpdateDelistingRequest.php new file mode 100644 index 00000000..e929cd5f --- /dev/null +++ b/extend/taobao/request/ItemUpdateDelistingRequest.php @@ -0,0 +1,49 @@ +numIid = $numIid; + $this->apiParas["num_iid"] = $numIid; + } + + public function getNumIid() + { + return $this->numIid; + } + + public function getApiMethodName() + { + return "taobao.item.update.delisting"; + } + + public function getApiParas() + { + return $this->apiParas; + } + + public function check() + { + + RequestCheckUtil::checkNotNull($this->numIid,"numIid"); + RequestCheckUtil::checkMinValue($this->numIid,0,"numIid"); + } + + public function putOtherTextParam($key, $value) { + $this->apiParas[$key] = $value; + $this->$key = $value; + } +} diff --git a/extend/taobao/request/ItemUpdateListingRequest.php b/extend/taobao/request/ItemUpdateListingRequest.php new file mode 100644 index 00000000..db9dfa73 --- /dev/null +++ b/extend/taobao/request/ItemUpdateListingRequest.php @@ -0,0 +1,67 @@ +num = $num; + $this->apiParas["num"] = $num; + } + + public function getNum() + { + return $this->num; + } + + public function setNumIid($numIid) + { + $this->numIid = $numIid; + $this->apiParas["num_iid"] = $numIid; + } + + public function getNumIid() + { + return $this->numIid; + } + + public function getApiMethodName() + { + return "taobao.item.update.listing"; + } + + public function getApiParas() + { + return $this->apiParas; + } + + public function check() + { + + RequestCheckUtil::checkNotNull($this->num,"num"); + RequestCheckUtil::checkMinValue($this->num,0,"num"); + RequestCheckUtil::checkNotNull($this->numIid,"numIid"); + RequestCheckUtil::checkMinValue($this->numIid,0,"numIid"); + } + + public function putOtherTextParam($key, $value) { + $this->apiParas[$key] = $value; + $this->$key = $value; + } +} diff --git a/extend/taobao/request/ItempropvaluesGetRequest.php b/extend/taobao/request/ItempropvaluesGetRequest.php new file mode 100644 index 00000000..cfe0c8c7 --- /dev/null +++ b/extend/taobao/request/ItempropvaluesGetRequest.php @@ -0,0 +1,131 @@ +attrKeys = $attrKeys; + $this->apiParas["attr_keys"] = $attrKeys; + } + + public function getAttrKeys() + { + return $this->attrKeys; + } + + public function setCid($cid) + { + $this->cid = $cid; + $this->apiParas["cid"] = $cid; + } + + public function getCid() + { + return $this->cid; + } + + public function setDatetime($datetime) + { + $this->datetime = $datetime; + $this->apiParas["datetime"] = $datetime; + } + + public function getDatetime() + { + return $this->datetime; + } + + public function setFields($fields) + { + $this->fields = $fields; + $this->apiParas["fields"] = $fields; + } + + public function getFields() + { + return $this->fields; + } + + public function setPvs($pvs) + { + $this->pvs = $pvs; + $this->apiParas["pvs"] = $pvs; + } + + public function getPvs() + { + return $this->pvs; + } + + public function setType($type) + { + $this->type = $type; + $this->apiParas["type"] = $type; + } + + public function getType() + { + return $this->type; + } + + public function getApiMethodName() + { + return "taobao.itempropvalues.get"; + } + + public function getApiParas() + { + return $this->apiParas; + } + + public function check() + { + + RequestCheckUtil::checkMaxListSize($this->attrKeys,20,"attrKeys"); + RequestCheckUtil::checkNotNull($this->cid,"cid"); + RequestCheckUtil::checkNotNull($this->fields,"fields"); + RequestCheckUtil::checkMaxListSize($this->fields,20,"fields"); + } + + public function putOtherTextParam($key, $value) { + $this->apiParas[$key] = $value; + $this->$key = $value; + } +} diff --git a/extend/taobao/request/KfcKeywordSearchRequest.php b/extend/taobao/request/KfcKeywordSearchRequest.php new file mode 100644 index 00000000..f6fc7574 --- /dev/null +++ b/extend/taobao/request/KfcKeywordSearchRequest.php @@ -0,0 +1,85 @@ +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/extend/taobao/request/OpenAccountCreateRequest.php b/extend/taobao/request/OpenAccountCreateRequest.php new file mode 100644 index 00000000..d894f9c1 --- /dev/null +++ b/extend/taobao/request/OpenAccountCreateRequest.php @@ -0,0 +1,47 @@ +paramList = $paramList; + $this->apiParas["param_list"] = $paramList; + } + + public function getParamList() + { + return $this->paramList; + } + + public function getApiMethodName() + { + return "taobao.open.account.create"; + } + + public function getApiParas() + { + return $this->apiParas; + } + + public function check() + { + + } + + public function putOtherTextParam($key, $value) { + $this->apiParas[$key] = $value; + $this->$key = $value; + } +} diff --git a/extend/taobao/request/OpenAccountDeleteRequest.php b/extend/taobao/request/OpenAccountDeleteRequest.php new file mode 100644 index 00000000..b0f15120 --- /dev/null +++ b/extend/taobao/request/OpenAccountDeleteRequest.php @@ -0,0 +1,65 @@ +isvAccountIds = $isvAccountIds; + $this->apiParas["isv_account_ids"] = $isvAccountIds; + } + + public function getIsvAccountIds() + { + return $this->isvAccountIds; + } + + public function setOpenAccountIds($openAccountIds) + { + $this->openAccountIds = $openAccountIds; + $this->apiParas["open_account_ids"] = $openAccountIds; + } + + public function getOpenAccountIds() + { + return $this->openAccountIds; + } + + public function getApiMethodName() + { + return "taobao.open.account.delete"; + } + + public function getApiParas() + { + return $this->apiParas; + } + + public function check() + { + + RequestCheckUtil::checkMaxListSize($this->isvAccountIds,20,"isvAccountIds"); + RequestCheckUtil::checkMaxListSize($this->openAccountIds,20,"openAccountIds"); + } + + public function putOtherTextParam($key, $value) { + $this->apiParas[$key] = $value; + $this->$key = $value; + } +} diff --git a/extend/taobao/request/OpenAccountIndexFindRequest.php b/extend/taobao/request/OpenAccountIndexFindRequest.php new file mode 100644 index 00000000..810a749e --- /dev/null +++ b/extend/taobao/request/OpenAccountIndexFindRequest.php @@ -0,0 +1,63 @@ +indexType = $indexType; + $this->apiParas["index_type"] = $indexType; + } + + public function getIndexType() + { + return $this->indexType; + } + + public function setIndexValue($indexValue) + { + $this->indexValue = $indexValue; + $this->apiParas["index_value"] = $indexValue; + } + + public function getIndexValue() + { + return $this->indexValue; + } + + public function getApiMethodName() + { + return "taobao.open.account.index.find"; + } + + public function getApiParas() + { + return $this->apiParas; + } + + public function check() + { + + } + + public function putOtherTextParam($key, $value) { + $this->apiParas[$key] = $value; + $this->$key = $value; + } +} diff --git a/extend/taobao/request/OpenAccountListRequest.php b/extend/taobao/request/OpenAccountListRequest.php new file mode 100644 index 00000000..5d21998f --- /dev/null +++ b/extend/taobao/request/OpenAccountListRequest.php @@ -0,0 +1,65 @@ +isvAccountIds = $isvAccountIds; + $this->apiParas["isv_account_ids"] = $isvAccountIds; + } + + public function getIsvAccountIds() + { + return $this->isvAccountIds; + } + + public function setOpenAccountIds($openAccountIds) + { + $this->openAccountIds = $openAccountIds; + $this->apiParas["open_account_ids"] = $openAccountIds; + } + + public function getOpenAccountIds() + { + return $this->openAccountIds; + } + + public function getApiMethodName() + { + return "taobao.open.account.list"; + } + + public function getApiParas() + { + return $this->apiParas; + } + + public function check() + { + + RequestCheckUtil::checkMaxListSize($this->isvAccountIds,20,"isvAccountIds"); + RequestCheckUtil::checkMaxListSize($this->openAccountIds,20,"openAccountIds"); + } + + public function putOtherTextParam($key, $value) { + $this->apiParas[$key] = $value; + $this->$key = $value; + } +} diff --git a/extend/taobao/request/OpenAccountSearchRequest.php b/extend/taobao/request/OpenAccountSearchRequest.php new file mode 100644 index 00000000..7a0c30cb --- /dev/null +++ b/extend/taobao/request/OpenAccountSearchRequest.php @@ -0,0 +1,48 @@ +query = $query; + $this->apiParas["query"] = $query; + } + + public function getQuery() + { + return $this->query; + } + + public function getApiMethodName() + { + return "taobao.open.account.search"; + } + + public function getApiParas() + { + return $this->apiParas; + } + + public function check() + { + + RequestCheckUtil::checkNotNull($this->query,"query"); + } + + public function putOtherTextParam($key, $value) { + $this->apiParas[$key] = $value; + $this->$key = $value; + } +} diff --git a/extend/taobao/request/OpenAccountTokenApplyRequest.php b/extend/taobao/request/OpenAccountTokenApplyRequest.php new file mode 100644 index 00000000..4c85d1aa --- /dev/null +++ b/extend/taobao/request/OpenAccountTokenApplyRequest.php @@ -0,0 +1,127 @@ +ext = $ext; + $this->apiParas["ext"] = $ext; + } + + public function getExt() + { + return $this->ext; + } + + public function setIsvAccountId($isvAccountId) + { + $this->isvAccountId = $isvAccountId; + $this->apiParas["isv_account_id"] = $isvAccountId; + } + + public function getIsvAccountId() + { + return $this->isvAccountId; + } + + public function setLoginStateExpireIn($loginStateExpireIn) + { + $this->loginStateExpireIn = $loginStateExpireIn; + $this->apiParas["login_state_expire_in"] = $loginStateExpireIn; + } + + public function getLoginStateExpireIn() + { + return $this->loginStateExpireIn; + } + + public function setOpenAccountId($openAccountId) + { + $this->openAccountId = $openAccountId; + $this->apiParas["open_account_id"] = $openAccountId; + } + + public function getOpenAccountId() + { + return $this->openAccountId; + } + + public function setTokenTimestamp($tokenTimestamp) + { + $this->tokenTimestamp = $tokenTimestamp; + $this->apiParas["token_timestamp"] = $tokenTimestamp; + } + + public function getTokenTimestamp() + { + return $this->tokenTimestamp; + } + + public function setUuid($uuid) + { + $this->uuid = $uuid; + $this->apiParas["uuid"] = $uuid; + } + + public function getUuid() + { + return $this->uuid; + } + + public function getApiMethodName() + { + return "taobao.open.account.token.apply"; + } + + public function getApiParas() + { + return $this->apiParas; + } + + public function check() + { + + } + + public function putOtherTextParam($key, $value) { + $this->apiParas[$key] = $value; + $this->$key = $value; + } +} diff --git a/extend/taobao/request/OpenAccountTokenValidateRequest.php b/extend/taobao/request/OpenAccountTokenValidateRequest.php new file mode 100644 index 00000000..f791089f --- /dev/null +++ b/extend/taobao/request/OpenAccountTokenValidateRequest.php @@ -0,0 +1,48 @@ +paramToken = $paramToken; + $this->apiParas["param_token"] = $paramToken; + } + + public function getParamToken() + { + return $this->paramToken; + } + + public function getApiMethodName() + { + return "taobao.open.account.token.validate"; + } + + public function getApiParas() + { + return $this->apiParas; + } + + public function check() + { + + RequestCheckUtil::checkNotNull($this->paramToken,"paramToken"); + } + + public function putOtherTextParam($key, $value) { + $this->apiParas[$key] = $value; + $this->$key = $value; + } +} diff --git a/extend/taobao/request/OpenAccountUpdateRequest.php b/extend/taobao/request/OpenAccountUpdateRequest.php new file mode 100644 index 00000000..d164e49f --- /dev/null +++ b/extend/taobao/request/OpenAccountUpdateRequest.php @@ -0,0 +1,47 @@ +paramList = $paramList; + $this->apiParas["param_list"] = $paramList; + } + + public function getParamList() + { + return $this->paramList; + } + + public function getApiMethodName() + { + return "taobao.open.account.update"; + } + + public function getApiParas() + { + return $this->apiParas; + } + + public function check() + { + + } + + public function putOtherTextParam($key, $value) { + $this->apiParas[$key] = $value; + $this->$key = $value; + } +} diff --git a/extend/taobao/request/OpenuidGetBymixnickRequest.php b/extend/taobao/request/OpenuidGetBymixnickRequest.php new file mode 100644 index 00000000..c18d9a90 --- /dev/null +++ b/extend/taobao/request/OpenuidGetBymixnickRequest.php @@ -0,0 +1,48 @@ +mixNick = $mixNick; + $this->apiParas["mix_nick"] = $mixNick; + } + + public function getMixNick() + { + return $this->mixNick; + } + + public function getApiMethodName() + { + return "taobao.openuid.get.bymixnick"; + } + + public function getApiParas() + { + return $this->apiParas; + } + + public function check() + { + + RequestCheckUtil::checkNotNull($this->mixNick,"mixNick"); + } + + public function putOtherTextParam($key, $value) { + $this->apiParas[$key] = $value; + $this->$key = $value; + } +} diff --git a/extend/taobao/request/OpenuidGetBytradeRequest.php b/extend/taobao/request/OpenuidGetBytradeRequest.php new file mode 100644 index 00000000..19e0f59f --- /dev/null +++ b/extend/taobao/request/OpenuidGetBytradeRequest.php @@ -0,0 +1,48 @@ +tid = $tid; + $this->apiParas["tid"] = $tid; + } + + public function getTid() + { + return $this->tid; + } + + public function getApiMethodName() + { + return "taobao.openuid.get.bytrade"; + } + + public function getApiParas() + { + return $this->apiParas; + } + + public function check() + { + + RequestCheckUtil::checkNotNull($this->tid,"tid"); + } + + public function putOtherTextParam($key, $value) { + $this->apiParas[$key] = $value; + $this->$key = $value; + } +} diff --git a/extend/taobao/request/OpenuidGetRequest.php b/extend/taobao/request/OpenuidGetRequest.php new file mode 100644 index 00000000..82ec5ef4 --- /dev/null +++ b/extend/taobao/request/OpenuidGetRequest.php @@ -0,0 +1,32 @@ +apiParas; + } + + public function check() + { + + } + + public function putOtherTextParam($key, $value) { + $this->apiParas[$key] = $value; + $this->$key = $value; + } +} diff --git a/extend/taobao/request/ProductAddRequest.php b/extend/taobao/request/ProductAddRequest.php new file mode 100644 index 00000000..95095c0a --- /dev/null +++ b/extend/taobao/request/ProductAddRequest.php @@ -0,0 +1,277 @@ + +非关键属性不包含关键属性、销售属性、用户自定义属性、商品属性; +
调用taobao.itemprops.get获取pid,调用taobao.itempropvalues.get获取vid.
注:支持最大长度为512字节 + **/ + private $binds; + + /** + * 商品类目ID.调用taobao.itemcats.get获取;注意:必须是叶子类目 id. + **/ + private $cid; + + /** + * 用户自定义属性,结构:pid1:value1;pid2:value2,如果有型号,系列等子属性用: 隔开 例如:“20000:优衣库:型号:001;632501:1234”,表示“品牌:优衣库:型号:001;货号:1234” +
注:包含所有自定义属性的传入 + **/ + private $customerProps; + + /** + * 产品描述.最大不超过25000个字符 + **/ + private $desc; + + /** + * 产品主图片.最大1M,目前仅支持GIF,JPG. + **/ + private $image; + + /** + * 是不是主图 + **/ + private $major; + + /** + * 上市时间。目前只支持鞋城类目传入此参数 + **/ + private $marketTime; + + /** + * 产品名称,最大30个字符. + **/ + private $name; + + /** + * native_unkeyprops + **/ + private $nativeUnkeyprops; + + /** + * 外部产品ID + **/ + private $outerId; + + /** + * 产品市场价.精确到2位小数;单位为元.如:200.07 + **/ + private $price; + + /** + * 销售属性值别名。格式为pid1:vid1:alias1;pid1:vid2:alia2。只有少数销售属性值支持传入别名,比如颜色和尺寸 + **/ + private $propertyAlias; + + /** + * 关键属性 结构:pid:vid;pid:vid.调用taobao.itemprops.get获取pid,调用taobao.itempropvalues.get获取vid;如果碰到用户自定义属性,请用customer_props. + **/ + private $props; + + /** + * 销售属性结构:pid:vid;pid:vid.调用taobao.itemprops.get获取is_sale_prop=true的pid,调用taobao.itempropvalues.get获取vid. + **/ + private $saleProps; + + /** + * 加入垂直市场,目前只支持以鞋城卖家身份加入名鞋馆(暂时此字段还不起作用,不对外开放) + **/ + private $verticalMarket; + + private $apiParas = array(); + + public function setBinds($binds) + { + $this->binds = $binds; + $this->apiParas["binds"] = $binds; + } + + public function getBinds() + { + return $this->binds; + } + + public function setCid($cid) + { + $this->cid = $cid; + $this->apiParas["cid"] = $cid; + } + + public function getCid() + { + return $this->cid; + } + + public function setCustomerProps($customerProps) + { + $this->customerProps = $customerProps; + $this->apiParas["customer_props"] = $customerProps; + } + + public function getCustomerProps() + { + return $this->customerProps; + } + + public function setDesc($desc) + { + $this->desc = $desc; + $this->apiParas["desc"] = $desc; + } + + public function getDesc() + { + return $this->desc; + } + + public function setImage($image) + { + $this->image = $image; + $this->apiParas["image"] = $image; + } + + public function getImage() + { + return $this->image; + } + + public function setMajor($major) + { + $this->major = $major; + $this->apiParas["major"] = $major; + } + + public function getMajor() + { + return $this->major; + } + + public function setMarketTime($marketTime) + { + $this->marketTime = $marketTime; + $this->apiParas["market_time"] = $marketTime; + } + + public function getMarketTime() + { + return $this->marketTime; + } + + public function setName($name) + { + $this->name = $name; + $this->apiParas["name"] = $name; + } + + public function getName() + { + return $this->name; + } + + public function setNativeUnkeyprops($nativeUnkeyprops) + { + $this->nativeUnkeyprops = $nativeUnkeyprops; + $this->apiParas["native_unkeyprops"] = $nativeUnkeyprops; + } + + public function getNativeUnkeyprops() + { + return $this->nativeUnkeyprops; + } + + public function setOuterId($outerId) + { + $this->outerId = $outerId; + $this->apiParas["outer_id"] = $outerId; + } + + public function getOuterId() + { + return $this->outerId; + } + + public function setPrice($price) + { + $this->price = $price; + $this->apiParas["price"] = $price; + } + + public function getPrice() + { + return $this->price; + } + + public function setPropertyAlias($propertyAlias) + { + $this->propertyAlias = $propertyAlias; + $this->apiParas["property_alias"] = $propertyAlias; + } + + public function getPropertyAlias() + { + return $this->propertyAlias; + } + + public function setProps($props) + { + $this->props = $props; + $this->apiParas["props"] = $props; + } + + public function getProps() + { + return $this->props; + } + + public function setSaleProps($saleProps) + { + $this->saleProps = $saleProps; + $this->apiParas["sale_props"] = $saleProps; + } + + public function getSaleProps() + { + return $this->saleProps; + } + + public function setVerticalMarket($verticalMarket) + { + $this->verticalMarket = $verticalMarket; + $this->apiParas["vertical_market"] = $verticalMarket; + } + + public function getVerticalMarket() + { + return $this->verticalMarket; + } + + public function getApiMethodName() + { + return "taobao.product.add"; + } + + public function getApiParas() + { + return $this->apiParas; + } + + public function check() + { + + RequestCheckUtil::checkMaxLength($this->binds,512,"binds"); + RequestCheckUtil::checkNotNull($this->cid,"cid"); + RequestCheckUtil::checkNotNull($this->image,"image"); + } + + public function putOtherTextParam($key, $value) { + $this->apiParas[$key] = $value; + $this->$key = $value; + } +} diff --git a/extend/taobao/request/ProductGetRequest.php b/extend/taobao/request/ProductGetRequest.php new file mode 100644 index 00000000..8ce57f23 --- /dev/null +++ b/extend/taobao/request/ProductGetRequest.php @@ -0,0 +1,96 @@ +cid = $cid; + $this->apiParas["cid"] = $cid; + } + + public function getCid() + { + return $this->cid; + } + + public function setFields($fields) + { + $this->fields = $fields; + $this->apiParas["fields"] = $fields; + } + + public function getFields() + { + return $this->fields; + } + + public function setProductId($productId) + { + $this->productId = $productId; + $this->apiParas["product_id"] = $productId; + } + + public function getProductId() + { + return $this->productId; + } + + public function setProps($props) + { + $this->props = $props; + $this->apiParas["props"] = $props; + } + + public function getProps() + { + return $this->props; + } + + public function getApiMethodName() + { + return "taobao.product.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/extend/taobao/request/ProductImgUploadRequest.php b/extend/taobao/request/ProductImgUploadRequest.php new file mode 100644 index 00000000..32f54bd6 --- /dev/null +++ b/extend/taobao/request/ProductImgUploadRequest.php @@ -0,0 +1,113 @@ +id = $id; + $this->apiParas["id"] = $id; + } + + public function getId() + { + return $this->id; + } + + public function setImage($image) + { + $this->image = $image; + $this->apiParas["image"] = $image; + } + + public function getImage() + { + return $this->image; + } + + public function setIsMajor($isMajor) + { + $this->isMajor = $isMajor; + $this->apiParas["is_major"] = $isMajor; + } + + public function getIsMajor() + { + return $this->isMajor; + } + + public function setPosition($position) + { + $this->position = $position; + $this->apiParas["position"] = $position; + } + + public function getPosition() + { + return $this->position; + } + + public function setProductId($productId) + { + $this->productId = $productId; + $this->apiParas["product_id"] = $productId; + } + + public function getProductId() + { + return $this->productId; + } + + public function getApiMethodName() + { + return "taobao.product.img.upload"; + } + + public function getApiParas() + { + return $this->apiParas; + } + + public function check() + { + + RequestCheckUtil::checkNotNull($this->image,"image"); + RequestCheckUtil::checkNotNull($this->productId,"productId"); + } + + public function putOtherTextParam($key, $value) { + $this->apiParas[$key] = $value; + $this->$key = $value; + } +} diff --git a/extend/taobao/request/ProductPropimgUploadRequest.php b/extend/taobao/request/ProductPropimgUploadRequest.php new file mode 100644 index 00000000..86e0ab57 --- /dev/null +++ b/extend/taobao/request/ProductPropimgUploadRequest.php @@ -0,0 +1,114 @@ +id = $id; + $this->apiParas["id"] = $id; + } + + public function getId() + { + return $this->id; + } + + public function setImage($image) + { + $this->image = $image; + $this->apiParas["image"] = $image; + } + + public function getImage() + { + return $this->image; + } + + public function setPosition($position) + { + $this->position = $position; + $this->apiParas["position"] = $position; + } + + public function getPosition() + { + return $this->position; + } + + public function setProductId($productId) + { + $this->productId = $productId; + $this->apiParas["product_id"] = $productId; + } + + public function getProductId() + { + return $this->productId; + } + + public function setProps($props) + { + $this->props = $props; + $this->apiParas["props"] = $props; + } + + public function getProps() + { + return $this->props; + } + + public function getApiMethodName() + { + return "taobao.product.propimg.upload"; + } + + public function getApiParas() + { + return $this->apiParas; + } + + public function check() + { + + RequestCheckUtil::checkNotNull($this->image,"image"); + RequestCheckUtil::checkNotNull($this->productId,"productId"); + RequestCheckUtil::checkNotNull($this->props,"props"); + } + + public function putOtherTextParam($key, $value) { + $this->apiParas[$key] = $value; + $this->$key = $value; + } +} diff --git a/extend/taobao/request/ProductUpdateRequest.php b/extend/taobao/request/ProductUpdateRequest.php new file mode 100644 index 00000000..1280c635 --- /dev/null +++ b/extend/taobao/request/ProductUpdateRequest.php @@ -0,0 +1,192 @@ +binds = $binds; + $this->apiParas["binds"] = $binds; + } + + public function getBinds() + { + return $this->binds; + } + + public function setDesc($desc) + { + $this->desc = $desc; + $this->apiParas["desc"] = $desc; + } + + public function getDesc() + { + return $this->desc; + } + + public function setImage($image) + { + $this->image = $image; + $this->apiParas["image"] = $image; + } + + public function getImage() + { + return $this->image; + } + + public function setMajor($major) + { + $this->major = $major; + $this->apiParas["major"] = $major; + } + + public function getMajor() + { + return $this->major; + } + + public function setName($name) + { + $this->name = $name; + $this->apiParas["name"] = $name; + } + + public function getName() + { + return $this->name; + } + + public function setNativeUnkeyprops($nativeUnkeyprops) + { + $this->nativeUnkeyprops = $nativeUnkeyprops; + $this->apiParas["native_unkeyprops"] = $nativeUnkeyprops; + } + + public function getNativeUnkeyprops() + { + return $this->nativeUnkeyprops; + } + + public function setOuterId($outerId) + { + $this->outerId = $outerId; + $this->apiParas["outer_id"] = $outerId; + } + + public function getOuterId() + { + return $this->outerId; + } + + public function setPrice($price) + { + $this->price = $price; + $this->apiParas["price"] = $price; + } + + public function getPrice() + { + return $this->price; + } + + public function setProductId($productId) + { + $this->productId = $productId; + $this->apiParas["product_id"] = $productId; + } + + public function getProductId() + { + return $this->productId; + } + + public function setSaleProps($saleProps) + { + $this->saleProps = $saleProps; + $this->apiParas["sale_props"] = $saleProps; + } + + public function getSaleProps() + { + return $this->saleProps; + } + + public function getApiMethodName() + { + return "taobao.product.update"; + } + + public function getApiParas() + { + return $this->apiParas; + } + + public function check() + { + + RequestCheckUtil::checkNotNull($this->productId,"productId"); + } + + public function putOtherTextParam($key, $value) { + $this->apiParas[$key] = $value; + $this->$key = $value; + } +} diff --git a/extend/taobao/request/ProductsSearchRequest.php b/extend/taobao/request/ProductsSearchRequest.php new file mode 100644 index 00000000..a4c2dc46 --- /dev/null +++ b/extend/taobao/request/ProductsSearchRequest.php @@ -0,0 +1,227 @@ +barcodeStr = $barcodeStr; + $this->apiParas["barcode_str"] = $barcodeStr; + } + + public function getBarcodeStr() + { + return $this->barcodeStr; + } + + public function setCid($cid) + { + $this->cid = $cid; + $this->apiParas["cid"] = $cid; + } + + public function getCid() + { + return $this->cid; + } + + public function setCustomerProps($customerProps) + { + $this->customerProps = $customerProps; + $this->apiParas["customer_props"] = $customerProps; + } + + public function getCustomerProps() + { + return $this->customerProps; + } + + public function setFields($fields) + { + $this->fields = $fields; + $this->apiParas["fields"] = $fields; + } + + public function getFields() + { + return $this->fields; + } + + public function setMarketId($marketId) + { + $this->marketId = $marketId; + $this->apiParas["market_id"] = $marketId; + } + + public function getMarketId() + { + return $this->marketId; + } + + public function setPageNo($pageNo) + { + $this->pageNo = $pageNo; + $this->apiParas["page_no"] = $pageNo; + } + + public function getPageNo() + { + return $this->pageNo; + } + + public function setPageSize($pageSize) + { + $this->pageSize = $pageSize; + $this->apiParas["page_size"] = $pageSize; + } + + public function getPageSize() + { + return $this->pageSize; + } + + public function setProps($props) + { + $this->props = $props; + $this->apiParas["props"] = $props; + } + + public function getProps() + { + return $this->props; + } + + public function setQ($q) + { + $this->q = $q; + $this->apiParas["q"] = $q; + } + + public function getQ() + { + return $this->q; + } + + public function setStatus($status) + { + $this->status = $status; + $this->apiParas["status"] = $status; + } + + public function getStatus() + { + return $this->status; + } + + public function setSuiteItemsStr($suiteItemsStr) + { + $this->suiteItemsStr = $suiteItemsStr; + $this->apiParas["suite_items_str"] = $suiteItemsStr; + } + + public function getSuiteItemsStr() + { + return $this->suiteItemsStr; + } + + public function setVerticalMarket($verticalMarket) + { + $this->verticalMarket = $verticalMarket; + $this->apiParas["vertical_market"] = $verticalMarket; + } + + public function getVerticalMarket() + { + return $this->verticalMarket; + } + + public function getApiMethodName() + { + return "taobao.products.search"; + } + + public function getApiParas() + { + return $this->apiParas; + } + + public function check() + { + + RequestCheckUtil::checkNotNull($this->fields,"fields"); + RequestCheckUtil::checkMaxListSize($this->fields,20,"fields"); + RequestCheckUtil::checkMaxLength($this->status,20,"status"); + } + + public function putOtherTextParam($key, $value) { + $this->apiParas[$key] = $value; + $this->$key = $value; + } +} diff --git a/extend/taobao/request/TbkCouponGetRequest.php b/extend/taobao/request/TbkCouponGetRequest.php new file mode 100644 index 00000000..9c1e02b3 --- /dev/null +++ b/extend/taobao/request/TbkCouponGetRequest.php @@ -0,0 +1,79 @@ +activityId = $activityId; + $this->apiParas["activity_id"] = $activityId; + } + + public function getActivityId() + { + return $this->activityId; + } + + public function setItemId($itemId) + { + $this->itemId = $itemId; + $this->apiParas["item_id"] = $itemId; + } + + public function getItemId() + { + return $this->itemId; + } + + public function setMe($me) + { + $this->me = $me; + $this->apiParas["me"] = $me; + } + + public function getMe() + { + return $this->me; + } + + public function getApiMethodName() + { + return "taobao.tbk.coupon.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/extend/taobao/request/TbkDgNewuserOrderGetRequest.php b/extend/taobao/request/TbkDgNewuserOrderGetRequest.php new file mode 100644 index 00000000..fa2d2460 --- /dev/null +++ b/extend/taobao/request/TbkDgNewuserOrderGetRequest.php @@ -0,0 +1,128 @@ +activityId = $activityId; + $this->apiParas["activity_id"] = $activityId; + } + + public function getActivityId() + { + return $this->activityId; + } + + public function setAdzoneId($adzoneId) + { + $this->adzoneId = $adzoneId; + $this->apiParas["adzone_id"] = $adzoneId; + } + + public function getAdzoneId() + { + return $this->adzoneId; + } + + public function setEndTime($endTime) + { + $this->endTime = $endTime; + $this->apiParas["end_time"] = $endTime; + } + + public function getEndTime() + { + return $this->endTime; + } + + public function setPageNo($pageNo) + { + $this->pageNo = $pageNo; + $this->apiParas["page_no"] = $pageNo; + } + + public function getPageNo() + { + return $this->pageNo; + } + + public function setPageSize($pageSize) + { + $this->pageSize = $pageSize; + $this->apiParas["page_size"] = $pageSize; + } + + public function getPageSize() + { + return $this->pageSize; + } + + public function setStartTime($startTime) + { + $this->startTime = $startTime; + $this->apiParas["start_time"] = $startTime; + } + + public function getStartTime() + { + return $this->startTime; + } + + public function getApiMethodName() + { + return "taobao.tbk.dg.newuser.order.get"; + } + + public function getApiParas() + { + return $this->apiParas; + } + + public function check() + { + + RequestCheckUtil::checkNotNull($this->activityId,"activityId"); + } + + public function putOtherTextParam($key, $value) { + $this->apiParas[$key] = $value; + $this->$key = $value; + } +} diff --git a/extend/taobao/request/TbkDgNewuserOrderSumRequest.php b/extend/taobao/request/TbkDgNewuserOrderSumRequest.php new file mode 100644 index 00000000..5f59451c --- /dev/null +++ b/extend/taobao/request/TbkDgNewuserOrderSumRequest.php @@ -0,0 +1,132 @@ +activityId = $activityId; + $this->apiParas["activity_id"] = $activityId; + } + + public function getActivityId() + { + return $this->activityId; + } + + public function setAdzoneId($adzoneId) + { + $this->adzoneId = $adzoneId; + $this->apiParas["adzone_id"] = $adzoneId; + } + + public function getAdzoneId() + { + return $this->adzoneId; + } + + public function setPageNo($pageNo) + { + $this->pageNo = $pageNo; + $this->apiParas["page_no"] = $pageNo; + } + + public function getPageNo() + { + return $this->pageNo; + } + + public function setPageSize($pageSize) + { + $this->pageSize = $pageSize; + $this->apiParas["page_size"] = $pageSize; + } + + public function getPageSize() + { + return $this->pageSize; + } + + public function setSettleMonth($settleMonth) + { + $this->settleMonth = $settleMonth; + $this->apiParas["settle_month"] = $settleMonth; + } + + public function getSettleMonth() + { + return $this->settleMonth; + } + + public function setSiteId($siteId) + { + $this->siteId = $siteId; + $this->apiParas["site_id"] = $siteId; + } + + public function getSiteId() + { + return $this->siteId; + } + + public function getApiMethodName() + { + return "taobao.tbk.dg.newuser.order.sum"; + } + + public function getApiParas() + { + return $this->apiParas; + } + + public function check() + { + + RequestCheckUtil::checkNotNull($this->activityId,"activityId"); + RequestCheckUtil::checkNotNull($this->pageNo,"pageNo"); + RequestCheckUtil::checkNotNull($this->pageSize,"pageSize"); + RequestCheckUtil::checkMaxValue($this->pageSize,100,"pageSize"); + RequestCheckUtil::checkMinValue($this->pageSize,1,"pageSize"); + } + + public function putOtherTextParam($key, $value) { + $this->apiParas[$key] = $value; + $this->$key = $value; + } +} diff --git a/extend/taobao/request/TbkDgOptimusMaterialRequest.php b/extend/taobao/request/TbkDgOptimusMaterialRequest.php new file mode 100644 index 00000000..a1fd4ef0 --- /dev/null +++ b/extend/taobao/request/TbkDgOptimusMaterialRequest.php @@ -0,0 +1,209 @@ +adzoneId = $adzoneId; + $this->apiParas["adzone_id"] = $adzoneId; + } + + public function getAdzoneId() + { + return $this->adzoneId; + } + + public function setContentId($contentId) + { + $this->contentId = $contentId; + $this->apiParas["content_id"] = $contentId; + } + + public function getContentId() + { + return $this->contentId; + } + + public function setContentSource($contentSource) + { + $this->contentSource = $contentSource; + $this->apiParas["content_source"] = $contentSource; + } + + public function getContentSource() + { + return $this->contentSource; + } + + public function setDeviceEncrypt($deviceEncrypt) + { + $this->deviceEncrypt = $deviceEncrypt; + $this->apiParas["device_encrypt"] = $deviceEncrypt; + } + + public function getDeviceEncrypt() + { + return $this->deviceEncrypt; + } + + public function setDeviceType($deviceType) + { + $this->deviceType = $deviceType; + $this->apiParas["device_type"] = $deviceType; + } + + public function getDeviceType() + { + return $this->deviceType; + } + + public function setDeviceValue($deviceValue) + { + $this->deviceValue = $deviceValue; + $this->apiParas["device_value"] = $deviceValue; + } + + public function getDeviceValue() + { + return $this->deviceValue; + } + + public function setFavoritesId($favoritesId) + { + $this->favoritesId = $favoritesId; + $this->apiParas["favorites_id"] = $favoritesId; + } + + public function getFavoritesId() + { + return $this->favoritesId; + } + + public function setItemId($itemId) + { + $this->itemId = $itemId; + $this->apiParas["item_id"] = $itemId; + } + + public function getItemId() + { + return $this->itemId; + } + + public function setMaterialId($materialId) + { + $this->materialId = $materialId; + $this->apiParas["material_id"] = $materialId; + } + + public function getMaterialId() + { + return $this->materialId; + } + + public function setPageNo($pageNo) + { + $this->pageNo = $pageNo; + $this->apiParas["page_no"] = $pageNo; + } + + public function getPageNo() + { + return $this->pageNo; + } + + public function setPageSize($pageSize) + { + $this->pageSize = $pageSize; + $this->apiParas["page_size"] = $pageSize; + } + + public function getPageSize() + { + return $this->pageSize; + } + + public function getApiMethodName() + { + return "taobao.tbk.dg.optimus.material"; + } + + public function getApiParas() + { + return $this->apiParas; + } + + public function check() + { + + RequestCheckUtil::checkNotNull($this->adzoneId,"adzoneId"); + RequestCheckUtil::checkNotNull($this->materialId,"materialId"); + } + + public function putOtherTextParam($key, $value) { + $this->apiParas[$key] = $value; + $this->$key = $value; + } +} diff --git a/extend/taobao/request/TbkDgOptimusPromotionRequest.php b/extend/taobao/request/TbkDgOptimusPromotionRequest.php new file mode 100644 index 00000000..da922736 --- /dev/null +++ b/extend/taobao/request/TbkDgOptimusPromotionRequest.php @@ -0,0 +1,97 @@ +adzoneId = $adzoneId; + $this->apiParas["adzone_id"] = $adzoneId; + } + + public function getAdzoneId() + { + return $this->adzoneId; + } + + public function setPageNum($pageNum) + { + $this->pageNum = $pageNum; + $this->apiParas["page_num"] = $pageNum; + } + + public function getPageNum() + { + return $this->pageNum; + } + + public function setPageSize($pageSize) + { + $this->pageSize = $pageSize; + $this->apiParas["page_size"] = $pageSize; + } + + public function getPageSize() + { + return $this->pageSize; + } + + public function setPromotionId($promotionId) + { + $this->promotionId = $promotionId; + $this->apiParas["promotion_id"] = $promotionId; + } + + public function getPromotionId() + { + return $this->promotionId; + } + + public function getApiMethodName() + { + return "taobao.tbk.dg.optimus.promotion"; + } + + public function getApiParas() + { + return $this->apiParas; + } + + public function check() + { + + RequestCheckUtil::checkNotNull($this->adzoneId,"adzoneId"); + RequestCheckUtil::checkNotNull($this->promotionId,"promotionId"); + } + + public function putOtherTextParam($key, $value) { + $this->apiParas[$key] = $value; + $this->$key = $value; + } +} diff --git a/extend/taobao/request/TbkItemInfoGetRequest.php b/extend/taobao/request/TbkItemInfoGetRequest.php new file mode 100644 index 00000000..59872f81 --- /dev/null +++ b/extend/taobao/request/TbkItemInfoGetRequest.php @@ -0,0 +1,147 @@ +bizSceneId = $bizSceneId; + $this->apiParas["biz_scene_id"] = $bizSceneId; + } + + public function getBizSceneId() + { + return $this->bizSceneId; + } + + public function setIp($ip) + { + $this->ip = $ip; + $this->apiParas["ip"] = $ip; + } + + public function getIp() + { + return $this->ip; + } + + public function setManageItemPubId($manageItemPubId) + { + $this->manageItemPubId = $manageItemPubId; + $this->apiParas["manage_item_pub_id"] = $manageItemPubId; + } + + public function getManageItemPubId() + { + return $this->manageItemPubId; + } + + public function setNumIids($numIids) + { + $this->numIids = $numIids; + $this->apiParas["num_iids"] = $numIids; + } + + public function getNumIids() + { + return $this->numIids; + } + + public function setPlatform($platform) + { + $this->platform = $platform; + $this->apiParas["platform"] = $platform; + } + + public function getPlatform() + { + return $this->platform; + } + + public function setPromotionType($promotionType) + { + $this->promotionType = $promotionType; + $this->apiParas["promotion_type"] = $promotionType; + } + + public function getPromotionType() + { + return $this->promotionType; + } + + public function setRelationId($relationId) + { + $this->relationId = $relationId; + $this->apiParas["relation_id"] = $relationId; + } + + public function getRelationId() + { + return $this->relationId; + } + + public function getApiMethodName() + { + return "taobao.tbk.item.info.get"; + } + + public function getApiParas() + { + return $this->apiParas; + } + + public function check() + { + RequestCheckUtil::checkNotNull($this->numIids,"numIids"); + } + + public function putOtherTextParam($key, $value) { + $this->apiParas[$key] = $value; + $this->$key = $value; + } +} diff --git a/extend/taobao/request/TimeGetRequest.php b/extend/taobao/request/TimeGetRequest.php new file mode 100644 index 00000000..2f29df79 --- /dev/null +++ b/extend/taobao/request/TimeGetRequest.php @@ -0,0 +1,32 @@ +apiParas; + } + + public function check() + { + + } + + public function putOtherTextParam($key, $value) { + $this->apiParas[$key] = $value; + $this->$key = $value; + } +} diff --git a/extend/taobao/request/TopAuthTokenCreateRequest.php b/extend/taobao/request/TopAuthTokenCreateRequest.php new file mode 100644 index 00000000..33c6cb68 --- /dev/null +++ b/extend/taobao/request/TopAuthTokenCreateRequest.php @@ -0,0 +1,64 @@ +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/extend/taobao/request/TopAuthTokenRefreshRequest.php b/extend/taobao/request/TopAuthTokenRefreshRequest.php new file mode 100644 index 00000000..3c0ca2f7 --- /dev/null +++ b/extend/taobao/request/TopAuthTokenRefreshRequest.php @@ -0,0 +1,48 @@ +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/extend/taobao/request/TopIpoutGetRequest.php b/extend/taobao/request/TopIpoutGetRequest.php new file mode 100644 index 00000000..69801ac6 --- /dev/null +++ b/extend/taobao/request/TopIpoutGetRequest.php @@ -0,0 +1,32 @@ +apiParas; + } + + public function check() + { + + } + + public function putOtherTextParam($key, $value) { + $this->apiParas[$key] = $value; + $this->$key = $value; + } +} diff --git a/extend/taobao/request/TopSdkFeedbackUploadRequest.php b/extend/taobao/request/TopSdkFeedbackUploadRequest.php new file mode 100644 index 00000000..3764d1d8 --- /dev/null +++ b/extend/taobao/request/TopSdkFeedbackUploadRequest.php @@ -0,0 +1,64 @@ +content = $content; + $this->apiParas["content"] = $content; + } + + public function getContent() + { + return $this->content; + } + + public function setType($type) + { + $this->type = $type; + $this->apiParas["type"] = $type; + } + + public function getType() + { + return $this->type; + } + + public function getApiMethodName() + { + return "taobao.top.sdk.feedback.upload"; + } + + public function getApiParas() + { + return $this->apiParas; + } + + public function check() + { + + RequestCheckUtil::checkNotNull($this->type,"type"); + } + + public function putOtherTextParam($key, $value) { + $this->apiParas[$key] = $value; + $this->$key = $value; + } +} diff --git a/extend/taobao/request/TopSecretGetRequest.php b/extend/taobao/request/TopSecretGetRequest.php new file mode 100644 index 00000000..fdf71709 --- /dev/null +++ b/extend/taobao/request/TopSecretGetRequest.php @@ -0,0 +1,80 @@ +customerUserId = $customerUserId; + $this->apiParas["customer_user_id"] = $customerUserId; + } + + public function getCustomerUserId() + { + return $this->customerUserId; + } + + 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/extend/taobao/request/TopSecretRegisterRequest.php b/extend/taobao/request/TopSecretRegisterRequest.php new file mode 100644 index 00000000..6132898c --- /dev/null +++ b/extend/taobao/request/TopSecretRegisterRequest.php @@ -0,0 +1,32 @@ +apiParas; + } + + public function check() + { + + } + + public function putOtherTextParam($key, $value) { + $this->apiParas[$key] = $value; + $this->$key = $value; + } +} diff --git a/extend/taobao/request/TradeConfirmfeeGetRequest.php b/extend/taobao/request/TradeConfirmfeeGetRequest.php new file mode 100644 index 00000000..f95f153e --- /dev/null +++ b/extend/taobao/request/TradeConfirmfeeGetRequest.php @@ -0,0 +1,48 @@ +tid = $tid; + $this->apiParas["tid"] = $tid; + } + + public function getTid() + { + return $this->tid; + } + + public function getApiMethodName() + { + return "taobao.trade.confirmfee.get"; + } + + public function getApiParas() + { + return $this->apiParas; + } + + public function check() + { + + RequestCheckUtil::checkNotNull($this->tid,"tid"); + } + + public function putOtherTextParam($key, $value) { + $this->apiParas[$key] = $value; + $this->$key = $value; + } +} diff --git a/extend/taobao/security/MagicCrypt.php b/extend/taobao/security/MagicCrypt.php new file mode 100644 index 00000000..28c3ee5c --- /dev/null +++ b/extend/taobao/security/MagicCrypt.php @@ -0,0 +1,51 @@ + \ No newline at end of file diff --git a/extend/taobao/security/README.txt b/extend/taobao/security/README.txt new file mode 100644 index 00000000..455d616c --- /dev/null +++ b/extend/taobao/security/README.txt @@ -0,0 +1,8 @@ + +1,使用方式,参见SecurityTest.php + +2,建议使用本地缓存解密秘钥,可以使用系统实现的 YacCache 或者自己去实现 iCache 接口插入到 SecurityClient 中。 + +3,(必须安装) 加密框架依赖 mcrypt 扩展,安装参见 http://www.cnblogs.com/lihanbingboke/p/5534258.html + +4,(可选安装) YacCache 依赖 yac 扩展,安装参见 http://www.widuu.com/archives/09/792.html diff --git a/extend/taobao/security/SecretContext.php b/extend/taobao/security/SecretContext.php new file mode 100644 index 00000000..8f87970a --- /dev/null +++ b/extend/taobao/security/SecretContext.php @@ -0,0 +1,61 @@ +session.','.$this->encryptPhoneNum.','.$this->encryptNickNum.',' + .$this->encryptReceiverNameNum.','.$this->encryptSimpleNum.','.$this->encryptSearchNum.',' + .$this->decryptPhoneNum.','.$this->decryptNickNum.','.$this->decryptReceiverNameNum.',' + .$this->decryptSimpleNum.','.$this->decryptSearchNum.','.$this->searchPhoneNum.',' + .$this->searchNickNum.','.$this->searchReceiverNameNum.','.$this->searchSimpleNum.',' + .$this->searchSearchNum ; + } + + function __construct() + { + $this->lastUploadTime = time(); + } + } + + class SecretData + { + var $originalValue; + var $originalBase64Value; + var $secretVersion; + var $search; + + function __construct() + { + + } + } +?> \ No newline at end of file diff --git a/extend/taobao/security/SecretCounterUtil.php b/extend/taobao/security/SecretCounterUtil.php new file mode 100644 index 00000000..114253c8 --- /dev/null +++ b/extend/taobao/security/SecretCounterUtil.php @@ -0,0 +1,97 @@ +topClient = $client; + + $counterMap = array(); + } + + /* + * 如果不走缓存模式,析构即调用API回传统计信息 + */ + function __destruct() + { + if($this->cacheClient == null){ + + } + } + + function report($session) + { + $request = new TopSdkFeedbackUploadRequest; + } + + function setCacheClient($cache) + { + $this->cacheClient = $cache; + } + + function incrDecrypt($delt,$session,$type) + { + $item = getItem($session); + if($item == null){ + $item = new SecretCounter(); + putItem($session,$item); + } + + if($type == "nick"){ + $item->$decryptNickNum += $delt; + }else if($type == "receiver_name"){ + $item->$decryptReceiverNameNum += $delt ; + }else if($type == "phone"){ + $item->$decryptPhoneNum += $delt ; + }else if($type == "simple"){ + $item->$decryptSimpleNum += $delt ; + } + } + + function incrEncrypt($delt,$session,$type) + { + $item = getItem($session); + if($item == null){ + $item = new SecretCounter(); + putItem($session,$item); + } + + if($type == "nick"){ + $item->$encryptNickNum += $delt ; + }else if($type == "receiver_name"){ + $item->$encryptReceiverNameNum += $delt ; + }else if($type == "phone"){ + $item->$encryptPhoneNum += $delt ; + }else if($type == "simple"){ + $item->$encryptSimpleNum += $delt ; + } + } + + function getItem($session) + { + if($this->cacheClient == null){ + return $counterMap[$session]; + }else{ + return $this->cacheClient->getCache('s_'.$session); + } + } + + function putItem($session,$item) + { + if($this->cacheClient == null){ + $counterMap[$session] = $item; + }else{ + $this->cacheClient->setCache('s_'.$session,$item); + } + } + } +?> \ No newline at end of file diff --git a/extend/taobao/security/SecretGetRequest.php b/extend/taobao/security/SecretGetRequest.php new file mode 100644 index 00000000..0db24dce --- /dev/null +++ b/extend/taobao/security/SecretGetRequest.php @@ -0,0 +1,35 @@ +apiParas; + } + + public function setRandomNum($random){ + $this->apiParas['random_num'] = $random; + } + + public function setCustomerUserId($customId){ + $this->apiParas['customer_user_id'] = $customId; + } + + public function setSecretVersion($version){ + $this->apiParas['secret_version'] = $version; + } + + public function check(){} + + public function putOtherTextParam($key, $value) { + $this->apiParas[$key] = $value; + $this->$key = $value; + } +} diff --git a/extend/taobao/security/SecurityClient.php b/extend/taobao/security/SecurityClient.php new file mode 100644 index 00000000..cf176def --- /dev/null +++ b/extend/taobao/security/SecurityClient.php @@ -0,0 +1,543 @@ +topClient = $client; + $this->randomNum = $random; + $this->securityUtil = new SecurityUtil(); + } + + /** + * 设置缓存处理器 + */ + function setCacheClient($cache) + { + $this->cacheClient = $cache; + } + + /** + * 密文检索,在秘钥升级场景下兼容查询 + * + * @see #search(String, String, String, Long) + * @return + */ + function searchPrevious($data,$type,$session = null) + { + return $this->searchInner($data,$type,$session,-1); + } + + /** + * 密文检索(每个用户单独分配秘钥) + * + * @see #search(String, String, String, Long) + * @return + */ + function search($data,$type,$session = null) + { + return $this->searchInner($data,$type,$session,null); + } + + /** + * 密文检索。 手机号码格式:$base64(H-MAC(phone后4位))$ simple格式:base64(H-MAC(滑窗)) + * + * @param data + * 明文数据 + * @param type + * 加密字段类型(例如:simple\phone) + * @param session + * 用户身份,用户级加密必填 + * @param version + * 秘钥历史版本 + * @return + */ + function searchInner($data, $type, $session,$version) + { + if(empty($data) || empty($type)){ + return $data; + } + + $secretContext = null; + + $secretContext = $this->callSecretApiWithCache($session,$version); + $this->incrCounter(3,$type,$secretContext,true); + + if(empty($secretContext) || empty($secretContext->secret)) { + return $data; + } + + return $this->securityUtil->search($data, $type,$secretContext); + } + + + /** + * 单条数据解密,使用appkey级别公钥 + * 非加密数据直接返回原文 + */ + function decryptPublic($data,$type) + { + return $this->decrypt($data,$type,null); + } + /** + * 单条数据解密 + * 非加密数据直接返回原文 + */ + function decrypt($data,$type,$session) + { + if(empty($data) || empty($type)){ + return $data; + } + $secretData = $this->securityUtil->getSecretDataByType($data,$type); + if(empty($secretData)){ + return $data; + } + + if($this->securityUtil->isPublicData($data,$type)){ + $secretContext = $this->callSecretApiWithCache(null,$secretData->secretVersion); + } else { + $secretContext = $this->callSecretApiWithCache($session,$secretData->secretVersion); + } + $this->incrCounter(2,$type,$secretContext,true); + + return $this->securityUtil->decrypt($data,$type,$secretContext); + } + + /** + * 多条数据解密,使用appkey级别公钥 + * 非加密数据直接返回原文 + */ + function decryptBatchPublic($array,$type) + { + if(empty($array) || empty($type)){ + return null; + } + + $result = array(); + foreach ($array as $value) { + $secretData = $this->securityUtil->getSecretDataByType($value,$type); + $secretContext = $this->callSecretApiWithCache(null,$secretData->secretVersion); + + if(empty($secretData)){ + $result[$value] = $value; + }else{ + $result[$value] = $this->securityUtil->decrypt($value,$type,$secretContext); + $this->incrCounter(2,$type,$secretContext,true); + } + + $this->flushCounter($secretContext); + } + + return $result; + } + + /** + * 多条数据解密,必须是同一个type和用户,返回结果是 KV结果 + * 非加密数据直接返回原文 + */ + function decryptBatch($array,$type,$session) + { + if(empty($array) || empty($type)){ + return null; + } + + $result = array(); + foreach ($array as $value) { + $secretData = $this->securityUtil->getSecretDataByType($value,$type); + if(empty($secretData)){ + $result[$value] = $value; + } else if($this->securityUtil->isPublicData($value,$type)){ + $appContext = $this->callSecretApiWithCache(null,$secretData->secretVersion); + $result[$value] = $this->securityUtil->decrypt($value,$type,$appContext); + $this->incrCounter(2,$type,$appContext,false); + $this->flushCounter($appContext); + } else { + $secretContext = $this->callSecretApiWithCache($session,$secretData->secretVersion); + $result[$value] = $this->securityUtil->decrypt($value,$type,$secretContext); + $this->incrCounter(2,$type,$secretContext,false); + $this->flushCounter($secretContext); + } + } + + return $result; + } + + /** + * 使用上一版本秘钥解密,app级别公钥 + */ + function decryptPreviousPublic($data,$type) + { + $secretContext = $this->callSecretApiWithCache(null,-1); + return $this->securityUtil->decrypt($data,$type,$secretContext); + } + /** + * 使用上一版本秘钥解密,一般只用于更新秘钥 + */ + function decryptPrevious($data,$type,$session) + { + if($this->securityUtil->isPublicData($data,$type)){ + $secretContext = $this->callSecretApiWithCache(null,-1); + } else { + $secretContext = $this->callSecretApiWithCache($session,-1); + } + return $this->securityUtil->decrypt($data,$type,$secretContext); + } + + /** + * 加密单条数据,使用app级别公钥 + */ + function encryptPublic($data,$type,$version = null) + { + return $this->encrypt($data,$type,null,$version); + } + /** + * 加密单条数据 + */ + function encrypt($data,$type,$session = null,$version = null) + { + if(empty($data) || empty($type)){ + return null; + } + $secretContext = $this->callSecretApiWithCache($session,null); + $this->incrCounter(1,$type,$secretContext,true); + + return $this->securityUtil->encrypt($data,$type,$version,$secretContext); + } + + /** + * 加密多条数据,使用app级别公钥 + */ + function encryptBatchPublic($array,$type,$version = null) + { + if(empty($array) || empty($type)){ + return null; + } + $secretContext = $this->callSecretApiWithCache(null,null); + $result = array(); + foreach ($array as $value) { + $result[$value] = $this->securityUtil->encrypt($value,$type,$version,$secretContext); + $this->incrCounter(1,$type,$secretContext,false); + } + $this->flushCounter($secretContext); + + return $result; + } + + /** + * 加密多条数据,必须是同一个type和用户,返回结果是 KV结果 + */ + function encryptBatch($array,$type,$session,$version = null) + { + if(empty($array) || empty($type)){ + return null; + } + $secretContext = $this->callSecretApiWithCache($session,null); + $result = array(); + foreach ($array as $value) { + $result[$value] = $this->securityUtil->encrypt($value,$type,$version,$secretContext); + $this->incrCounter(1,$type,$secretContext,false); + } + $this->flushCounter($secretContext); + return $result; + } + + /** + * 使用上一版本秘钥加密,使用app级别公钥 + */ + function encryptPreviousPublic($data,$type) + { + $secretContext = $this->callSecretApiWithCache(null,-1); + $this->incrCounter(1,$type,$secretContext,true); + + return $this->securityUtil->encrypt($data,$type,$secretContext->version,$secretContext); + } + /** + * 使用上一版本秘钥加密,一般只用于更新秘钥 + */ + function encryptPrevious($data,$type,$session) + { + $secretContext = $this->callSecretApiWithCache($session,-1); + $this->incrCounter(1,$type,$secretContext,true); + + return $this->securityUtil->encrypt($data,$type,$secretContext); + } + + /** + * 根据session生成秘钥 + */ + function initSecret($session) + { + return $this->callSecretApiWithCache($session,null); + } + + function buildCacheKey($session,$secretVersion) + { + if(empty($session)){ + return $this->topClient->getAppkey(); + } + if(empty($secretVersion)){ + return $session ; + } + return $session.'_'.$secretVersion ; + } + + + function generateCustomerSession($userId) + { + return '_'.$userId ; + } + + /** + * 判断是否是已加密的数据 + */ + function isEncryptData($data,$type) + { + if(empty($data) || empty($type)){ + return false; + } + return $this->securityUtil->isEncryptData($data,$type); + } + + /** + * 判断是否是已加密的数据,数据必须是同一个类型 + */ + function isEncryptDataArray($array,$type) + { + if(empty($array) || empty($type)){ + return false; + } + return $this->securityUtil->isEncryptDataArray($array,$type); + } + + /** + * 判断数组中的数据是否存在密文,存在任何一个返回true,否则false + */ + function isPartEncryptData($array,$type) + { + if(empty($array) || empty($type)){ + return false; + } + return $this->securityUtil->isPartEncryptData($array,$type); + } + + /** + * 获取秘钥,使用缓存 + */ + function callSecretApiWithCache($session,$secretVersion) + { + if($this->cacheClient) + { + $time = time(); + $cacheKey = $this->buildCacheKey($session,$secretVersion); + $secretContext = $this->cacheClient->getCache($cacheKey); + + if($secretContext) + { + if($this->canUpload($secretContext)){ + if($this->report($secretContext)){ + $this->clearReport($secretContext); + } + } + } + + if($secretContext && $secretContext->invalidTime > $time) + { + return $secretContext; + } + } + + $secretContext = $this->callSecretApi($session,$secretVersion); + + if($this->cacheClient) + { + $secretContext->cacheKey = $cacheKey; + $this->cacheClient->setCache($cacheKey,$secretContext); + } + + return $secretContext; + } + + function incrCounter($op,$type,$secretContext,$flush) + { + if($op == 1){ + switch ($type) { + case 'nick': + $secretContext->encryptNickNum ++ ; + break; + case 'simple': + $secretContext->encryptSimpleNum ++ ; + break; + case 'receiver_name': + $secretContext->encryptReceiverNameNum ++ ; + break; + case 'phone': + $secretContext->encryptPhoneNum ++ ; + break; + default: + break; + } + }else if($op == 2){ + switch ($type) { + case 'nick': + $secretContext->decryptNickNum ++ ; + break; + case 'simple': + $secretContext->decryptSimpleNum ++ ; + break; + case 'receiver_name': + $secretContext->decryptReceiverNameNum ++ ; + break; + case 'phone': + $secretContext->decryptPhoneNum ++ ; + break; + default: + break; + } + }else{ + switch ($type) { + case 'nick': + $secretContext->searchNickNum ++ ; + break; + case 'simple': + $secretContext->searchSimpleNum ++ ; + break; + case 'receiver_name': + $secretContext->searchReceiverNameNum ++ ; + break; + case 'phone': + $secretContext->searchPhoneNum ++ ; + break; + default: + break; + } + } + + if($flush && $this->cacheClient){ + $this->cacheClient->setCache($secretContext->cacheKey,$secretContext); + } + } + + function flushCounter($secretContext) + { + if($this->cacheClient){ + $this->cacheClient->setCache($secretContext->cacheKey,$secretContext); + } + } + + function clearReport($secretContext) + { + $secretContext->encryptPhoneNum = 0; + $secretContext->encryptNickNum = 0; + $secretContext->encryptReceiverNameNum = 0; + $secretContext->encryptSimpleNum = 0; + $secretContext->encryptSearchNum = 0; + $secretContext->decryptPhoneNum = 0; + $secretContext->decryptNickNum = 0; + $secretContext->decryptReceiverNameNum = 0; + $secretContext->decryptSimpleNum = 0; + $secretContext->decryptSearchNum = 0; + $secretContext->searchPhoneNum = 0; + $secretContext->searchNickNum = 0; + $secretContext->searchReceiverNameNum = 0; + $secretContext->searchSimpleNum = 0; + $secretContext->searchSearchNum = 0; + $secretContext->lastUploadTime = time(); + } + + function canUpload($secretContext) + { + $current = time(); + if($current - $secretContext->lastUploadTime > 300){ + return true; + } + return false; + } + + /* + * 上报信息 + */ + function report($secretContext) + { + $request = new TopSdkFeedbackUploadRequest; + $request->setContent($secretContext->toLogString()); + + if(empty($secretContext->session)){ + $request->setType(APP_SECRET_TYPE); + }else{ + $request->setType(APP_USER_SECRET_TYPE); + } + + $response = $this->topClient->execute($request,$secretContext->session); + if($response->code == 0){ + return true; + } + return false; + } + + /** + * 获取秘钥,不使用缓存 + */ + function callSecretApi($session,$secretVersion) + { + $request = new TopSecretGetRequest; + $request->setRandomNum($this->randomNum); + if($secretVersion) + { + if(intval($secretVersion) < 0 || $session == null){ + $session = null; + $secretVersion = -1 * intval($secretVersion < 0); + } + $request->setSecretVersion($secretVersion); + } + + $topSession = $session; + if($session != null && $session[0] == '_') + { + $request->setCustomerUserId(substr($session,1)); + $topSession = null; + } + + $response = $this->topClient->execute($request,$topSession); + if($response->code != 0){ + throw new Exception($response->msg); + } + + $time = time(); + $secretContext = new SecretContext(); + $secretContext->maxInvalidTime = $time + intval($response->max_interval); + $secretContext->invalidTime = $time + intval($response->interval); + $secretContext->secret = strval($response->secret); + $secretContext->session = $session; + if(!empty($response->app_config)){ + $tmpJson = json_decode($response->app_config); + $appConfig = array(); + foreach ($tmpJson as $key => $value){ + $appConfig[$key] = $value; + } + $secretContext->appConfig = $appConfig; + } + + if(empty($session)){ + $secretContext->secretVersion = -1 * intval($response->secret_version); + }else{ + $secretContext->secretVersion = intval($response->secret_version); + } + return $secretContext; + } + } +?> \ No newline at end of file diff --git a/extend/taobao/security/SecurityTest.php b/extend/taobao/security/SecurityTest.php new file mode 100644 index 00000000..1ea923bd --- /dev/null +++ b/extend/taobao/security/SecurityTest.php @@ -0,0 +1,68 @@ +appkey = '576216'; + $c->secretKey = 'd1e44cec2f6c8a2c73342595b711decc'; + $c->gatewayUrl = 'https://10.218.128.111/router/rest'; + + $session = '6101701a21788e0e44743d5f1032ccd5276f00ea6a2d9092050695162'; + + $client = new SecurityClient($c,'S7/xdg4AD7WooWY7+g11qoBpaVsEkonULDJPEiMcXPE='); + $yac = new YacCache; + $client->setCacheClient($yac); + + $type = 'phone'; + $val = '13834566786'; + + echo "原文:13834566786".PHP_EOL; + $encryptValue = $client->encrypt($val,$type,$session); + echo "加密后:".$encryptValue.PHP_EOL; + echo "search明文:".$val." -->".$client->search("6786",$type,$session).PHP_EOL; + + if($client->isEncryptData($encryptValue,$type)) + { + $originalValue = $client->decrypt($encryptValue,$type,$session); + echo "解密后:".$originalValue.PHP_EOL; + } + + $originalValue = $client->decrypt('~YjW+T6rCmKcc0tGqzWIDaQ==~-113~','nick',$session); + echo "公钥解密后:".$originalValue.PHP_EOL; + + + $secArray = array('~YjW+T6rCmKcc0tGqzWIDaQ==~-113~'); + $client->decryptBatch($secArray,'nick',$session); + + + $typeArray = array('normal','nick','receiver_name'); + + $val2 = '啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊看哦【啊啊啊的'; + + foreach ($typeArray as $type2) { + echo "==============================TOP================================".PHP_EOL; + $encty2 = $client->encrypt($val2,$type2,$session); + echo $type2."|明文:".$val2." ---->密文:".$encty2.PHP_EOL; + if($client->isEncryptData($encty2,$type2)) + { + $originalValue = $client->decrypt($encty2,$type2,$session); + echo "解密后:".$originalValue.PHP_EOL; + echo "search明文:".$originalValue." -->".$client->search($originalValue,$type2,$session).PHP_EOL; + }else{ + echo "不是加密数据".PHP_EOL; + } + } + + $encryptNick = $client->encrypt("xxxuxxxuxxxu","nick"); + echo "加密后:".$encryptNick.PHP_EOL; + echo "search明文:xxxuxxxuxxxu -->".$client->search("xxxu","nick").PHP_EOL; + if($client->isEncryptData($encryptNick,"nick")) + { + $originalNick = $client->decryptPublic($encryptNick,"nick"); + echo "解密后:".$originalNick.PHP_EOL; + }else{ + echo "不是加密数据 ".$encryptNick.PHP_EOL; + } +?> \ No newline at end of file diff --git a/extend/taobao/security/SecurityUtil.php b/extend/taobao/security/SecurityUtil.php new file mode 100644 index 00000000..df0b2483 --- /dev/null +++ b/extend/taobao/security/SecurityUtil.php @@ -0,0 +1,589 @@ +SEPARATOR_CHAR_MAP['nick'] = NICK_SEPARATOR_CHAR; + $this->SEPARATOR_CHAR_MAP['simple'] = NICK_SEPARATOR_CHAR; + $this->SEPARATOR_CHAR_MAP['receiver_name'] = NICK_SEPARATOR_CHAR; + $this->SEPARATOR_CHAR_MAP['search'] = NICK_SEPARATOR_CHAR; + $this->SEPARATOR_CHAR_MAP['normal'] = NORMAL_SEPARATOR_CHAR; + $this->SEPARATOR_CHAR_MAP['phone'] = PHONE_SEPARATOR_CHAR; + + } + + /* + * 判断是否是base64格式的数据 + */ + function isBase64Str($str) + { + $strLen = strlen($str); + for($i = 0; $i < $strLen ; $i++) + { + if(!$this->isBase64Char($str[$i])) + { + return false; + } + } + return true; + } + + /* + * 判断是否是base64格式的字符 + */ + function isBase64Char($char) + { + return strpos($this->BASE64_ARRAY,$char) !== false; + } + + /* + * 使用sep字符进行trim + */ + function trimBySep($str,$sep) + { + $start = 0; + $end = strlen($str); + for($i = 0; $i < $end; $i++) + { + if($str[$i] == $sep) + { + $start = $i + 1; + } + else + { + break; + } + } + for($i = $end -1 ; $i >= 0; $i--) + { + if($str[$i] == $sep) + { + $end = $i - 1; + } + else + { + break; + } + } + return substr($str,$start,$end); + } + + function checkEncryptData($dataArray) + { + if(count($dataArray) == 2){ + return $this->isBase64Str($dataArray[0]); + }else{ + return $this->isBase64Str($dataArray[0]) && $this->isBase64Str($dataArray[1]); + } + } + + /* + * 判断是否是加密数据 + */ + function isEncryptDataArray($array,$type) + { + foreach ($array as $value) { + if(!$this->isEncryptData($value,$type)){ + return false; + } + } + return true; + } + + /** + * 判断是否是已加密的数据,数据必须是同一个类型 + */ + function isPartEncryptData($array,$type) + { + $result = false; + foreach ($array as $value) { + if($this->isEncryptData($value,$type)){ + $result = true; + break; + } + } + return $result; + } + + /* + * 判断是否是加密数据 + */ + function isEncryptData($data,$type) + { + if(!is_string($data) || strlen($data) < 4) + { + return false; + } + + $separator = $this->SEPARATOR_CHAR_MAP[$type]; + $strlen = strlen($data); + if($data[0] != $separator || $data[$strlen -1] != $separator) + { + return false; + } + + $dataArray = explode($separator,$this->trimBySep($data,$separator)); + $arrayLength = count($dataArray); + + if($separator == PHONE_SEPARATOR_CHAR) + { + if($arrayLength != 3) + { + return false; + } + if($data[$strlen - 2] == $separator) + { + return $this->checkEncryptData($dataArray); + } + else + { + $version = $dataArray[$arrayLength -1]; + if(is_numeric($version)) + { + $base64Val = $dataArray[$arrayLength -2]; + return $this->isBase64Str($base64Val); + } + } + }else{ + if($data[strlen($data) - 2] == $separator && $arrayLength == 3) + { + return $this->checkEncryptData($dataArray); + } + else if($arrayLength == 2) + { + return $this->checkEncryptData($dataArray); + } + else + { + return false; + } + } + } + + function search($data, $type,$secretContext) + { + $separator = $this->SEPARATOR_CHAR_MAP[$type]; + if('phone' == $type) { + if (strlen($data) != 4 ) { + throw new Exception("phoneNumber error"); + } + return $separator.$this->hmacMD5EncryptToBase64($data, $secretContext->secret).$separator; + } else { + $compressLen = $this->getArrayValue($secretContext->appConfig,'encrypt_index_compress_len',3); + $slideSize = $this->getArrayValue($secretContext->appConfig,'encrypt_slide_size',4); + + $slideList = $this->getSlideWindows($data, $slideSize); + $builder = ''; + foreach ($slideList as $slide) { + $builder .= $this->hmacMD5EncryptToBase64($slide,$secretContext->secret,$compressLen); + } + return $builder; + } + } + + /* + * 加密逻辑 + */ + function encrypt($data,$type,$version,$secretContext) + { + if(!is_string($data)) + { + return false; + } + + $separator = $this->SEPARATOR_CHAR_MAP[$type]; + $isIndexEncrypt = $this->isIndexEncrypt($type,$version,$secretContext); + if($isIndexEncrypt || $type == "search"){ + if('phone' == $type) { + return $this->encryptPhoneIndex($data,$separator,$secretContext); + } else { + $compressLen = $this->getArrayValue($secretContext->appConfig,'encrypt_index_compress_len',3); + $slideSize = $this->getArrayValue($secretContext->appConfig,'encrypt_slide_size',4); + return $this->encryptNormalIndex($data,$compressLen,$slideSize,$separator,$secretContext); + } + }else{ + if('phone' == $type) { + return $this->encryptPhone($data,$separator,$secretContext); + } else { + return $this->encryptNormal($data,$separator,$secretContext); + } + } + + } + + /* + * 加密逻辑,手机号码格式 + */ + function encryptPhone($data,$separator,$secretContext) + { + $len = strlen($data); + if($len < 11) + { + return $data; + } + $prefixNumber = substr($data,0,$len -8); + $last8Number = substr($data,$len -8,$len); + + return $separator.$prefixNumber.$separator.Security::encrypt($last8Number,$secretContext->secret) + .$separator.$secretContext->secretVersion.$separator ; + } + + /* + * 加密逻辑,非手机号码格式 + */ + function encryptNormal($data,$separator,$secretContext) + { + return $separator.Security::encrypt($data,$secretContext->secret) + .$separator.$secretContext->secretVersion.$separator; + } + + /* + * 解密逻辑 + */ + function decrypt($data,$type,$secretContext) + { + if(!$this->isEncryptData($data,$type)) + { + throw new Exception("数据[".$data."]不是类型为[".$type."]的加密数据"); + } + $dataLen = strlen($data); + $separator = $this->SEPARATOR_CHAR_MAP[$type]; + + $secretData = null; + if($data[$dataLen - 2] == $separator){ + $secretData = $this->getIndexSecretData($data,$separator); + }else{ + $secretData = $this->getSecretData($data,$separator); + } + + if($secretData == null){ + return $data; + } + + $result = Security::decrypt($secretData->originalBase64Value,$secretContext->secret); + + if($separator == PHONE_SEPARATOR_CHAR && !$secretData->search) + { + return $secretData->originalValue.$result; + } + return $result; + } + + /* + * 判断是否是公钥数据 + */ + function isPublicData($data,$type) + { + $secretData = $this->getSecretDataByType($data,$type); + if(empty($secretData)){ + return false; + } + if(intval($secretData->secretVersion) < 0){ + return true; + } + return false; + } + + function getSecretDataByType($data,$type) + { + $separator = $this->SEPARATOR_CHAR_MAP[$type]; + $dataLen = strlen($data); + + if($data[$dataLen - 2] == $separator){ + return $secretData = $this->getIndexSecretData($data,$separator); + }else{ + return $secretData = $this->getSecretData($data,$separator); + } + } + + /* + * 分解密文 + */ + function getSecretData($data,$separator) + { + $secretData = new SecretData; + $dataArray = explode($separator,$this->trimBySep($data,$separator)); + $arrayLength = count($dataArray); + + if($separator == PHONE_SEPARATOR_CHAR) + { + if($arrayLength != 3){ + return null; + }else{ + $version = $dataArray[2]; + if(is_numeric($version)) + { + $secretData->originalValue = $dataArray[0]; + $secretData->originalBase64Value = $dataArray[1]; + $secretData->secretVersion = $version; + } + } + } + else + { + if($arrayLength != 2){ + return null; + }else{ + $version = $dataArray[1]; + if(is_numeric($version)) + { + $secretData->originalBase64Value = $dataArray[0]; + $secretData->secretVersion = $version; + } + } + } + return $secretData; + } + + function getIndexSecretData($data,$separator) { + $secretData = new SecretData; + $dataArray = explode($separator,$this->trimBySep($data,$separator)); + $arrayLength = count($dataArray); + + if($separator == PHONE_SEPARATOR_CHAR) { + if ($arrayLength != 3) { + return null; + }else{ + $version = $dataArray[2]; + if(is_numeric($version)) + { + $secretData->originalValue = $dataArray[0]; + $secretData->originalBase64Value = $dataArray[1]; + $secretData->secretVersion = $version; + } + } + + } else { + if($arrayLength != 3){ + return null; + } else { + $version = $dataArray[2]; + if(is_numeric($version)) + { + $secretData->originalBase64Value = $dataArray[0]; + $secretData->originalValue = $dataArray[1]; + $secretData->secretVersion = $version; + } + } + } + + $secretData->search = true; + return $secretData; + } + + /** + * 判断密文是否支持检索 + * + * @param key + * @param version + * @return + */ + function isIndexEncrypt($key,$version,$secretContext) + { + if ($version != null && $version < 0) { + $key = "previous_".$key; + } else { + $key = "current_".$key; + } + + return $secretContext->appConfig != null && + array_key_exists($key,$secretContext->appConfig) && + $secretContext->appConfig[$key] == "2"; + } + + function isLetterOrDigit($ch) + { + $code = ord($ch); + if (0 <= $code && $code <= 127) { + return true; + } + return false; + } + + function utf8_strlen($string = null) { + // 将字符串分解为单元 + preg_match_all("/./us", $string, $match); + // 返回单元个数 + return count($match[0]); + } + + function utf8_substr($string,$start,$end) { + // 将字符串分解为单元 + preg_match_all("/./us", $string, $match); + // 返回单元个数 + $result = ""; + for($i = $start; $i < $end; $i++){ + $result .= $match[0][$i]; + } + return $result; + } + + function utf8_str_at($string,$index) { + // 将字符串分解为单元 + preg_match_all("/./us", $string, $match); + // 返回单元个数 + return $match[0][$index]; + } + + function compress($input,$toLength) { + if($toLength < 0) { + return null; + } + $output = array(); + for($i = 0; $i < $toLength; $i++) { + $output[$i] = chr(0); + } + $input = $this->getBytes($input); + $inputLength = count($input); + for ($i = 0; $i < $inputLength; $i++) { + $index_output = $i % $toLength; + $output[$index_output] = $output[$index_output] ^ $input[$i]; + } + return $output; + } + + /** + * @see #hmacMD5Encrypt + * + * @param encryptText + * 被签名的字符串 + * @param encryptKey + * 密钥 + * @param compressLen压缩长度 + * @return + * @throws Exception + */ + function hmacMD5EncryptToBase64($encryptText,$encryptKey,$compressLen = 0) { + $encryptResult = Security::hmac_md5($encryptText,$encryptKey); + if($compressLen != 0){ + $encryptResult = $this->compress($encryptResult,$compressLen); + } + return base64_encode($this->toStr($encryptResult)); + } + + + /** + * 生成滑动窗口 + * + * @param input + * @param slideSize + * @return + */ + function getSlideWindows($input,$slideSize = 4) + { + $endIndex = 0; + $startIndex = 0; + $currentWindowSize = 0; + $currentWindow = null; + $dataLength = $this->utf8_strlen($input); + $windows = array(); + while($endIndex < $dataLength || $currentWindowSize > $slideSize) + { + $startsWithLetterOrDigit = false; + if(!empty($currentWindow)){ + $startsWithLetterOrDigit = $this->isLetterOrDigit($this->utf8_str_at($currentWindow,0)); + } + if($endIndex == $dataLength && $startsWithLetterOrDigit == false){ + break; + } + if($currentWindowSize == $slideSize && + $startsWithLetterOrDigit == false && + $this->isLetterOrDigit($this->utf8_str_at($input,$endIndex))) { + $endIndex ++; + $currentWindow = $this->utf8_substr($input,$startIndex,$endIndex); + $currentWindowSize = 5; + } else { + if($endIndex != 0){ + if($startsWithLetterOrDigit){ + $currentWindowSize -= 1; + }else{ + $currentWindowSize -= 2; + } + $startIndex ++; + } + + while ($currentWindowSize < $slideSize && $endIndex < $dataLength) { + $currentChar = $this->utf8_str_at($input,$endIndex); + if ($this->isLetterOrDigit($currentChar)) { + $currentWindowSize += 1; + } else { + $currentWindowSize += 2; + } + $endIndex++; + } + $currentWindow = $this->utf8_substr($input,$startIndex,$endIndex); + } + array_push($windows,$currentWindow); + } + return $windows; + } + + function encryptPhoneIndex($data,$separator,$secretContext) { + $dataLength = strlen($data); + if($dataLength < 11) { + return $data; + } + $last4Number = substr($data,$dataLength -4 ,$dataLength); + return $separator.$this->hmacMD5EncryptToBase64($last4Number,$secretContext->secret).$separator + .Security::encrypt($data,$secretContext->secret).$separator.$secretContext->secretVersion + .$separator.$separator; + } + + function encryptNormalIndex($data,$compressLen,$slideSize,$separator,$secretContext) { + $slideList = $this->getSlideWindows($data, $slideSize); + $builder = ""; + foreach ($slideList as $slide) { + $builder .= $this->hmacMD5EncryptToBase64($slide,$secretContext->secret,$compressLen); + } + return $separator.Security::encrypt($data,$secretContext->secret).$separator.$builder.$separator + .$secretContext->secretVersion.$separator.$separator; + } + + function getArrayValue($array,$key,$default) { + if(array_key_exists($key, $array)){ + return $array[$key]; + } + return $default; + } + + function getBytes($string) { + $bytes = array(); + for($i = 0; $i < strlen($string); $i++){ + $bytes[] = ord($string[$i]); + } + return $bytes; + } + + function toStr($bytes) { + if(!is_array($bytes)){ + return $bytes; + } + $str = ''; + foreach($bytes as $ch) { + $str .= chr($ch); + } + return $str; + } + } +?> \ No newline at end of file diff --git a/extend/taobao/security/TopSdkFeedbackUploadRequest.php b/extend/taobao/security/TopSdkFeedbackUploadRequest.php new file mode 100644 index 00000000..2134ef9a --- /dev/null +++ b/extend/taobao/security/TopSdkFeedbackUploadRequest.php @@ -0,0 +1,62 @@ +content = $content; + $this->apiParas["content"] = $content; + } + + public function getContent() + { + return $this->content; + } + + public function setType($type) + { + $this->type = $type; + $this->apiParas["type"] = $type; + } + + public function getType() + { + return $this->type; + } + + public function getApiMethodName() + { + return "taobao.top.sdk.feedback.upload"; + } + + public function getApiParas() + { + return $this->apiParas; + } + + public function check() + { + } + + public function putOtherTextParam($key, $value) { + $this->apiParas[$key] = $value; + $this->$key = $value; + } +} diff --git a/extend/taobao/security/YacCache.php b/extend/taobao/security/YacCache.php new file mode 100644 index 00000000..13881627 --- /dev/null +++ b/extend/taobao/security/YacCache.php @@ -0,0 +1,38 @@ +isEnable = false; + } + + public function getCache($key) + { + $key = md5($key); + if($this->isEnable){ + $yac = new Yac(); + return $yac->get($key); + }else{ + echo "yac is not enable ,skip getCache"; + } + } + + public function setCache($key,$var) + { + $key = md5($key); + if($this->isEnable){ + $yac = new Yac(); + $yac->set($key, $var); + }else{ + echo "yac is not enable ,skip setCache"; + } + } +} + +?> \ No newline at end of file diff --git a/extend/taobao/security/iCache.php b/extend/taobao/security/iCache.php new file mode 100644 index 00000000..6a24afe7 --- /dev/null +++ b/extend/taobao/security/iCache.php @@ -0,0 +1,14 @@ + \ No newline at end of file diff --git a/extend/taobao/top/.DS_Store b/extend/taobao/top/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..ceba02d87202c4e448750941166ffc8fd289847f GIT binary patch literal 8196 zcmeHMT}&NC6g~$io!yqQ)K=JQTW%m&RBE||A8Tp7{M3pu=RvEjnm+j8gTDA^G@5v3W-n>^dGSGQx|7U& zGjq<_nRDjb9nJ*+usv%g04e~0QRS#@qGpZ4<-D#c1>sB)A(A~n25bmmHkI?IS7}ER zQ3Rq0L=lK05Je!0!2clvbZ7Iz*17kkG-{&=L=m_nBf!58ajG1XAudW3pAKq73P8wH z08yw43y?1k8^dxWQdCrr8%H92MkxnFhfDHI@!gA zI$%;_)J74ABCt9F{Pkhrg9T~G-kiUu94|$(E2(M6_JjKRYgkZNw4rz-V=7Zi)F=BV zy+`b=08&kYRQwKBrkHZ4*a8?s%~%e8x1 z*Yw46`lWy|g((wS`TTrCb4y*kexWWtpJ+%l*To-d+PAQvu=1M3fv)3Ivvc#O7oI&Q zUBmG60HrHjJ-?Qpjz7~O{VaGr@8|WrpNhIk?|NMA9=6k-+i%ZV6I!WHZg$bIFJsM+ zOG9bT$xgZcgjSX|oOISP0;|n&xUxSSSf>KsJLY?tphGB5Xj;~{j##8;&sd$LO{QD< zlX|BE+jIS+R>mi+PS(rqD@&WV@2tA_f%>M0AL+bWvZYij+p4O^C_rvtKV@5)!JKUd zlOu+owp`P8PYli2zMXQc0oRza$_hSIl&g1_SCr^6eMerj(u8T%Y&e^;pUK+6tXN}L zrLK;dw7VY907uVG}lE3nuXp9>&M83yq)eo4rx2S7HwmX9#%X5Q`&yFS#tHRZQFNM*Y0U(X>D6R(-o(9Go1v7 zBuNB$^5hW5cnc%>x$Cie)Sc_GdXTthono9o+D54zk5w_^j3!8<$7*7`84+765K{I2 z7-?o;g&)QqfqS0*g=>U{Pm(XFFN0_dVyicAV;Q zs=RQ$MTx?M8j+3@igcWC`5%VVkCQ65Nrt#6k!Gm;>puiU_doqT8r}bbe0Om3H+_ic A2LJ#7 literal 0 HcmV?d00001 diff --git a/route/api.php b/route/api.php index c27af5f9..a19ff21e 100644 --- a/route/api.php +++ b/route/api.php @@ -22,6 +22,7 @@ use think\facade\Route; Route::group('api/', function () { Route::any('test', 'api.Auth/test'); Route::any('dotest', 'api.Auth/dotest'); + Route::any('caiji', 'api.Auth/caiji'); Route::any('app/version', 'api.Auth/appVersion'); Route::post('merchant/syncStatus/:id', 'api.Auth/merchantStatus'); Route::get('business/agree', 'api.Auth/businessAgree');