|
@@ -325,32 +325,36 @@ class Shop extends Start_Controller {
|
|
|
header('Location:'.$setting['code'].'?response_type=code&client_id='.$setting['appkey'].'&redirect_uri='.'http://'.$_SERVER['HTTP_HOST'].'/shop/code'.'&state='.$arg_array[0].'&view=web&sp=ae');exit;
|
|
|
}
|
|
|
$code = $_GET['code'];
|
|
|
- $url = $setting['token'];
|
|
|
- $postfields= array('grant_type'=>'authorization_code',
|
|
|
- 'client_id'=>$setting['appkey'],
|
|
|
- 'client_secret'=>$setting['secret'],
|
|
|
- 'code'=>$_GET['code'],
|
|
|
- 'sp'=>'ae',
|
|
|
- 'redirect_uri'=>'http://'.$_SERVER['HTTP_HOST'].'/shop/code');
|
|
|
- $post_data = '';
|
|
|
- foreach($postfields as $key=>$value){
|
|
|
- $post_data .="$key=".urlencode($value)."&";}
|
|
|
+ // $url = $setting['token'];
|
|
|
+ // $postfields= array('grant_type'=>'authorization_code',
|
|
|
+ // 'client_id'=>$setting['appkey'],
|
|
|
+ // 'client_secret'=>$setting['secret'],
|
|
|
+ // 'code'=>$_GET['code'],
|
|
|
+ // 'sp'=>'ae',
|
|
|
+ // 'redirect_uri'=>'http://'.$_SERVER['HTTP_HOST'].'/shop/code');
|
|
|
+ // $post_data = '';
|
|
|
+ // foreach($postfields as $key=>$value){
|
|
|
+ // $post_data .="$key=".urlencode($value)."&";}
|
|
|
|
|
|
+ $tokenUrl = 'https://api.aliexpress.com/rest/token';
|
|
|
+ $postData = [
|
|
|
+ 'grant_type' => 'authorization_code',
|
|
|
+ 'client_id' => $$setting['appkey'],
|
|
|
+ 'client_secret' => $setting['secret'],
|
|
|
+ 'code' => $code,
|
|
|
+ 'redirect_uri' => 'http://'.$_SERVER['HTTP_HOST'].'/shop/code'
|
|
|
+ ];
|
|
|
|
|
|
- $url = 'http://39.100.97.180/smt.php';
|
|
|
+ // 发起 POST 请求
|
|
|
$ch = curl_init();
|
|
|
- curl_setopt($ch,CURLOPT_URL,$url);
|
|
|
- curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
|
|
|
- curl_setopt($ch,CURLOPT_HEADER,0);
|
|
|
- curl_setopt($ch,CURLOPT_POST, 1);
|
|
|
- curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,600);
|
|
|
- //设置post数据
|
|
|
- $post = array();
|
|
|
- $post['get_token_by_code'] = 1;
|
|
|
- $post['code'] = $code;
|
|
|
- curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($post));
|
|
|
- $output = curl_exec($ch);
|
|
|
+ curl_setopt($ch, CURLOPT_URL, $tokenUrl);
|
|
|
+ curl_setopt($ch, CURLOPT_POST, true);
|
|
|
+ curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($postData));
|
|
|
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
|
|
+ $response = curl_exec($ch);
|
|
|
curl_close($ch);
|
|
|
+ $output = $response;
|
|
|
+
|
|
|
|
|
|
|
|
|
// $ch = curl_init();
|
|
@@ -363,6 +367,14 @@ class Shop extends Start_Controller {
|
|
|
// //添加变量
|
|
|
// curl_setopt($ch, CURLOPT_POSTFIELDS, substr($post_data,0,-1));
|
|
|
// $output = curl_exec($ch);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
$output = json_decode($output,true);
|
|
|
echo "<pre>";
|
|
|
print_r($output);
|