学科网组卷API认证方式为Basic Authentication的请求

认证方式为Basic Authentication,请使用"Authorization"头携带凭据信息(索要凭据请联系组卷网)。 比如appId为testapp,secret为123的凭据为 testapp:123 使用base64编码后数据为dGVzdGFwcDoxMjM= ,那么请求头 Authorization 为 Basic dGVzdGFwcDoxMjM=

     $url = "http://api.xkw.com/zujuan/v2/";//请替换成真实的地址 我这里不方便漏出
     $arr_header[] = "Content-Type:application/json";
     $arr_header[] = "Authorization: Basic ".base64_encode("账号:密码"); //添加头,在name和pass处填写对应账号密码
 
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_URL,$url );
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     if(!empty($arr_header)){
              curl_setopt($ch, CURLOPT_HTTPHEADER, $arr_header);
        }
     $response = curl_exec($ch);
    curl_close($ch);
    $result=json_decode($response);