|
@@ -22,16 +22,44 @@ class Notify extends Start_Controller {
|
|
|
}
|
|
|
}
|
|
|
public function _smt(){
|
|
|
- echo "<pre>";
|
|
|
- var_dump("-----GET--开始----");
|
|
|
- print_r($_GET);
|
|
|
- var_dump("-----GET--结束----");
|
|
|
- var_dump("-----POST--开始----");
|
|
|
- print_r($_POST);
|
|
|
- var_dump("-----POST--结束----");
|
|
|
- var_dump("-----input--开始----");
|
|
|
- $res = file_get_contents('php://input');
|
|
|
- print_r($res);
|
|
|
- var_dump("-----input--结束----");
|
|
|
+ $appkey = '26004389';
|
|
|
+ $secretKey = 'd880d725c67b449c8a601e9b0766955d';
|
|
|
+ $code = isset($_GET['code']) ? $_GET['code'] : '';
|
|
|
+
|
|
|
+ // $code = $_POST['code'] ?? $authCode;
|
|
|
+
|
|
|
+ // 构建请求参数
|
|
|
+ $params = [
|
|
|
+ 'grant_type' => 'authorization_code',
|
|
|
+ 'client_id' => $appkey,
|
|
|
+ 'client_secret' => $secretKey,
|
|
|
+ 'code' => $code,
|
|
|
+ 'redirect_uri' => "https://1.wepolicy.cn/notify/smt"
|
|
|
+ ];
|
|
|
+
|
|
|
+ // 发送POST请求
|
|
|
+ $ch = curl_init('https://api.aliexpress.com/token');
|
|
|
+ curl_setopt($ch, CURLOPT_POST, true);
|
|
|
+ curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($params));
|
|
|
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
|
|
+ curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/x-www-form-urlencoded']);
|
|
|
+
|
|
|
+ $response = curl_exec($ch);
|
|
|
+ $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
|
|
+
|
|
|
+ if (curl_errno($ch)) {
|
|
|
+ throw new Exception('cURL Error: ' . curl_error($ch));
|
|
|
+ }
|
|
|
+
|
|
|
+ curl_close($ch);
|
|
|
+
|
|
|
+ // 处理响应
|
|
|
+ $data = json_decode($response, true);
|
|
|
+ echo "<pre>";
|
|
|
+ var_dump($data);
|
|
|
+
|
|
|
}
|
|
|
+
|
|
|
+ // https://api-sg.aliexpress.com/oauth/authorize?response_type=code&force_auth=true&redirect_url=https://1.wepolicy.cn/notify/smt&client_id=26004389
|
|
|
+
|
|
|
}
|