$productType, 'provinceCode' => $provinceCode, 'cityCode' => $cityCode, ); // 判断$searchValue是否为空 if (!empty($searchValue)) { $data['searchValue'] = $searchValue; $data['searchType'] = $searchType; } // 创建cURL资源 $curl = curl_init(); // 设置cURL选项 curl_setopt_array($curl, array( CURLOPT_URL => 'https://kapi.10010.com/kcardorder/intentionalOrder/selectNum?channel=' . urlencode($channel) . '&id=' . urlencode($uid), CURLOPT_RETURNTRANSFER => true, CURLOPT_POST => true, CURLOPT_POSTFIELDS => $data, CURLOPT_HTTPHEADER => array( 'Content-Type: multipart/form-data' ) )); // 发送请求并获取响应 $response = curl_exec($curl); // 检查是否有错误发生 if(curl_errno($curl)){ $error_msg = curl_error($curl); // 处理错误 } else { // 处理响应 $responseData = json_decode($response, true); // 输出返回的数据 if (!empty($responseData['data'])) { $data = array(); foreach ($responseData['data'] as $item) { if (isset($item['number'])) { $data[] = $item['number']; } } $output = array( 'code' => 200, 'message' => '获取成功', 'data' => $data ); } else { // 请求成功但没有数据的情况 $output = array( 'code' => 0, 'message' => '没有数据' ); } header('Content-Type: application/json'); echo json_encode($output); } // 关闭cURL资源 curl_close($curl); ?>