lvhao 4 주 전
부모
커밋
abdd95699e
1개의 변경된 파일23개의 추가작업 그리고 35개의 파일을 삭제
  1. 23 35
      core/CoreApp/controllers/Shop.php

+ 23 - 35
core/CoreApp/controllers/Shop.php

@@ -325,36 +325,33 @@ 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'
-			];
 
-			// 发起 POST 请求
+			$url = 'http://39.100.97.180/smt.php';
 			$ch = curl_init();
-			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_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;
+			var_dump($post);
+			curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($post));
+			$output = curl_exec($ch);
 			curl_close($ch);
-			$output = $response;
-
 
 
 			// $ch = curl_init();
@@ -367,18 +364,9 @@ 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);
-			die;
 			$this->shop->save(array('code'=>$output["access_token"],'codetime'=>substr($output["expire_time"],0,10)),$_GET['state']);
 			header('Location:http://'.$_SERVER['HTTP_HOST'].'/user/');exit;
 		}