Skip to content

29对接代码


此步骤非常重要,配置错误可能影响站点无法正常运营,建议不懂的小伙伴联系上级提供技术支持。
sh
#29对接需要添加请求函数 /Checkorder/configuration.php 在最底部添加以下代码
function httpRequest($method, $url, $data = [], $headers = [], $isJSON = false)
{
  // 初始化cURL会话
  $ch = curl_init();

  // 设置cURL选项
  curl_setopt($ch, CURLOPT_URL, $url);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // 获取数据返回而不是直接输出
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // 跳过SSL证书验证,适用于HTTPS请求
  curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);

  // 根据请求方法设置特定选项
  if (strtoupper($method) === 'POST') {
    curl_setopt($ch, CURLOPT_POST, true);
    if ($isJSON) {
      curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
    } else {
      curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
    }
  } else {
    // 如果是GET请求,并且有数据,则拼接到URL后面
    if (!empty($data)) {
      $url = $url . '?' . http_build_query($data);
      curl_setopt($ch, CURLOPT_URL, $url);
    }
  }

  // 设置请求头
  if ($isJSON) {
    $headersArray = ['Content-Type: application/json'];
  } else {
    $headersArray = ['Content-Type: application/x-www-form-urlencoded'];
  }
  if (!empty($headers)) {
    $headersArray = array_merge($headersArray, $headers);
  }
  curl_setopt($ch, CURLOPT_HTTPHEADER, $headersArray);

  // 执行cURL会话
  $response = curl_exec($ch);

  // 检查是否有错误发生
  if ($response === false) {
    echo '请求错误: ' . curl_error($ch);
  }

  // 关闭cURL资源,并且释放系统资源
  curl_close($ch);

  return $response;
}
sh
#qqcy标识 放在/Checkorder/xdjk.php 文件
"qqcy" => "青青草原学习平台",
sh
#qqcy下单接口 放在/Checkorder/xdjk.php 文件
else if ($type == "qqcy") {
    $data = array("token" => $a["pass"], "platform" => $noun, "school" => $school, "user" => $user, "pass" => $pass, "kcname" => $kcname, "kcid" => $kcid, "time" => $uTime, "score" => $uScore, "speed" => $d["study_speed"], "exam_submit" => $d["is_submit_exam"], "exam_time" => $d["exam_time"]);
    $ixx_url = $a["url"] . "/api/add";
    $result = httpRequest('POST', $ixx_url, $data, [], true);
    $result = json_decode($result, true);
    if ($result["code"] == "1") {
      $b = array("code" => 1, "msg" => "下单成功", "yid" => $result["id"]);
    } else {
      $b = array("code" => -1, "msg" => $result["msg"]);
    }
    return $b;
  }
sh
#qqcy查课接口 放在/Checkorder/ckjk.php 文件
 else if ($type == "qqcy") {
    $data = array("token" => $a["pass"], "school" => $school, "user" => $user, "pass" => $pass, "platform" => $noun);
    $ixx_url = $a["url"] . "/api/get";
    $result = httpRequest('POST', $ixx_url, $data, [], true);
    $result = json_decode($result, true);
    return $result;
  }
sh
#qqcy补刷接口 放在/Checkorder/bsjk.php 文件
  else if ($type == "qqcy") {
    $data = array("id" => $yid, "username" => $d['user']);
    $ixx_url = $a["url"] . "/api/reset";
    $result = httpRequest('POST', $ixx_url, $data, [], true);
    $result = json_decode($result, true);
    return $result;
  }
sh
#qqcy进度接口 放在/Checkorder/jdjk.php 文件
else if ($type == "qqcy") {
    $data = array("id" => $d['yid'], "username" => $user);
    $ixx_url = $a["url"] . "/api/refresh";
    $result = httpRequest('POST', $ixx_url, $data, [], true);
    $result = json_decode($result, true);
    if ($result["code"] == "1") {
      foreach ($result["data"] as $res) {
        $yid = $res["id"];
        $kcname = $res["kcname"];
        $status = $res["status"];
        $process = $res["process"];
        $remarks = $res["remarks"];
        $xxtremarks = $res["xxtremarks"];
        $kcks = $res["courseStartTime"];
        $kcjs = $res["courseEndTime"];
        $ksks = $res["examStartTime"];
        $ksjs = $res["examEndTime"];

        $b[] = array("code" => 1, "msg" => "查询成功", "yid" => $yid, "kcname" => $kcname, "user" => $user, "pass" => $pass, "ksks" => $ksks, "ksjs" => $ksjs, "status_text" => $status, "process" => $process, "remarks" => $remarks, "xxtremarks" => $xxtremarks);
      }
    } else {
      $b[] = array("code" => -1, "msg" => "查询失败,请联系管理员");
    }
    return $b;

  }
sh
#qqcy改密接口 放在/Checkorder/gmjk.php 文件
  if ($type == "qqcy") {
    $data = array("id" => $yid, "username" => $d['user'], "pass" => $new_pass);
    $ixx_url = $a["url"] . "/api/update";
    $result = httpRequest('POST', $ixx_url, $data, [], true);
    $result = json_decode($result, true);
    if ($result["code"] == "1") {
      $b = array("code" => 1, "msg" => "修改成功");
    } else {
      $b = array("code" => -1, "msg" => $result["msg"] ?: "修改失败");
    }
    return $b;
  }
sh
#qqcy暂停接口 放在/Checkorder/ztjk.php 文件
  if ($type == "qqcy") {
    $data = array("id" => $yid, "username" => $d['user']);
    $ixx_url = $a["url"] . "/api/stop";
    $result = httpRequest('POST', $ixx_url, $data, [], true);
    $result = json_decode($result, true);
    if ($result["code"] == 1) {
      $b = array("code" => 1, "msg" => $result["msg"]);
    } else {
      $b = array("code" => -1, "msg" => $result["msg"]);
    }
    return $b;
  }

Copyright@ 2025 米老鼠. All rights reserved.