12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- <?php
- include_once("../../untils/conn.php"); // 引入数据库连接配置文件
- // 查询SQL语句
- $sql = "SELECT * FROM config_api WHERE groups = 'Unicom'";
- // 执行查询
- $result = mysqli_query($con, $sql);
- // 获取结果
- $row = mysqli_fetch_assoc($result);
- $channel = $row['channel'];
- $uid = $row['uid'];
- $productType = $_POST['haokaid'];
- $searchValue = $_POST['searchValue'];
- // $productType = '1137';
- $provinceCode ='50';
- $cityCode = '501';
- $searchType ='02';
- // 构建请求参数数组
- $data = array(
- 'productType' => $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);
- ?>
|