年级数据API接口
        一、概述
        获取全品学堂学段说明
        
        
        二、如何使用
        应用创建后,会自动生成appid,appkey,然后将所需参数拼装成http请求,即可调用。支持php,java等。
        
        三、接口说明
        1. 接口描述
        
            
                
                    | url | 
                    https://open.canpoint.net/openapi/basedata/new_get_nianji | 
                
                
                    | 功能描述 | 
                    获取年级接口 | 
                
                
                    | 返回格式 | 
                    Json,utf8 | 
                
                
                    | HTTP请求方式 | 
                    get | 
                
            
         
        2. 请求描述
        2.1 请求参数(header)
        
            
                
                
                    | 参数名 | 
                    类型 | 
                    必填 | 
                    参数位置 | 
                    描述 | 
                    默认值 | 
                
                
                
                
                    | appid | 
                    string | 
                    是 | 
                    header | 
                    应用ID | 
                    无 | 
                
                
                
                
                    | appkey | 
                    string | 
                    是 | 
                    header | 
                    应用密钥 | 
                    无 | 
                
                
            
         
        2.2 输入参数(urlParam)
        
            
                
                
                    | 参数名 | 
                    类型 | 
                    必填 | 
                    参数位置 | 
                    描述 | 
                    默认值 | 
                
                
                
                
                    | xueduan_id | 
                    string | 
                    是 | 
                    urlParam | 
                    学段ID | 
                    无 | 
                
                
            
         
        2.3 输出参数
        
            
                
                
                    | 参数名 | 
                    类型 | 
                    必填 | 
                    描述 | 
                    默认值 | 
                
                
                
                
                    | result | 
                    int | 
                    是 | 
                    返回信息 | 
                    0 | 
                
                
                    | count | 
                    int | 
                    是 | 
                    返回总数 | 
                    0 | 
                
                
                    | msg | 
                    string | 
                    是 | 
                    返回描述 | 
                    空 | 
                
                
                    | data | 
                    array() | 
                    是 | 
                    返回值 | 
                    空 | 
                
                
                    | data['nianji_name'] | 
                    srting | 
                    是 | 
                    年级名字 | 
                    空 | 
                
                
                    | data['nianji_id'] | 
                    int | 
                    是 | 
                    年级ID | 
                    空 | 
                
                
                    | data['nianji_attrid'] | 
                    int | 
                    是 | 
                    年级属性ID | 
                    空 | 
                
                
            
         
        3.请求示例
        3.1 请求示例
        3.1.1 curl示例
        
            curl  --get --include  'https://open.canpoint.net/openapi/basedata/new_get_nianji?xueduan_id=获取的学段ID'  -H 'appid:您自己的appid \n appkey:您自己的appkey'
        
        3.1.2 php示例
        
            <?php 
            $ch = curl_init();
            $url = 'https://open.canpoint.net/openapi/basedata/new_get_nianji?xueduan_id=获取的学段ID';
            $header = array(
            'appid':您自己的appid',
            'appkey: 您自己的appkey'
            );
            // 添加apikey到header
            curl_setopt($ch, CURLOPT_HTTPHEADER  , $header);
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
            // 执行HTTP请求
            curl_setopt($ch , CURLOPT_URL , $url);
            $res = curl_exec($ch);
            
            var_dump(json_decode($res));
            ?>
        
        3.1.3 python示例
        
            # -*- coding: utf-8 -*-
            import sys, urllib, urllib2, json
            
            url = 'https://open.canpoint.net/openapi/basedata/get_xueduan?xueduan_id=获取的学段ID';
            
            req = urllib2.Request(url)
            
            req.add_header("appid", "您自己的appid")
            req.add_header("appkey", "您自己的appkey")
            
            resp = urllib2.urlopen(req)
            content = resp.read()
            if(content):
            print(content)
        
        3.1.4 java示例
        
            String httpUrl = "https://open.canpoint.net/openapi/basedata/new_get_nianji";
            String httpArg = "?xueduan_id=获取的学段ID';
            String jsonResult = request(httpUrl, httpArg);
            System.out.println(jsonResult);
            
            /**
            * @param urlAll
            *            :请求接口
            * @param httpArg
            *            :参数
            * @return 返回结果
            */
            public static String request(String httpUrl, String httpArg) {
            BufferedReader reader = null;
            String result = null;
            StringBuffer sbf = new StringBuffer();
            httpUrl = httpUrl + "?" + httpArg;
            
            try {
            URL url = new URL(httpUrl);
            HttpURLConnection connection = (HttpURLConnection) url
            .openConnection();
            connection.setRequestMethod("GET");
            // 填入apikey到HTTP header
            connection.setRequestProperty("appid",  "您自己的appid");
            connection.setRequestProperty("appkey",  "您自己的appkey");
            connection.connect();
            InputStream is = connection.getInputStream();
            reader = new BufferedReader(new InputStreamReader(is, "UTF-8"));
            String strRead = null;
            while ((strRead = reader.readLine()) != null) {
            sbf.append(strRead);
            sbf.append("rn");
            }
            reader.close();
            result = sbf.toString();
            } catch (Exception e) {
            e.printStackTrace();
            }
            return result;
            }
        
        3.1.5 C#示例
        
            string url = "https://open.canpoint.net/openapi/basedata/new_get_nianji";
            string param = "?xueduan_id=获取的学段ID';
            string result = request(url,param);
            
            /// 
            /// 发送HTTP请求
            /// 
            /// 
请求的URL
            /// 
请求的参数
            /// 
请求结果
            public static string request(string url, string param)
            {
            string strURL = url + '?' + param;
            System.Net.HttpWebRequest request;
            request = (System.Net.HttpWebRequest)WebRequest.Create(strURL);
            request.Method = "GET";
            // 添加header
            request.Headers.Add("appid", "您自己的appid");
            request.Headers.Add("appkey", "您自己的appkey");
            System.Net.HttpWebResponse response;
            response = (System.Net.HttpWebResponse)request.GetResponse();
            System.IO.Stream s;
            s = response.GetResponseStream();
            string StrDate = "";
            string strValue = "";
            StreamReader Reader = new StreamReader(s, Encoding.UTF8);
            while ((StrDate = Reader.ReadLine()) != null)
            {
            strValue += StrDate + "rn";
            }
            return strValue;
            }
        
 
        3.2 返回值
        {
                               "result": 0,
                               "count": 1,
                               "msg": "",
                               "data": {
                               "3": {
                               "nianji_name": "八年级",
                               "nianji_id": "100009",
                               "nianji_attrid": "1000014"
                               }
                               }
                               }
        
        4. 错误参照码
        
            
                
                
                    | 错误码 | 
                    错误码返回说明 | 
                
                
                
                
                    | 0 | 
                    成功返回 | 
                
                
                    | 1010 | 
                    应用appid错误 | 
                
                
                    | 1012 | 
                    商户id错误 | 
                
                
                    | 1013 | 
                    TOKEN超时 | 
                
                
                    | 1014 | 
                    TOKEN失效 | 
                
                
                    | 1015 | 
                    该视频不在应用服务内 | 
                
                
                    | 1016 | 
                    TOKEN不存在 | 
                
                
                    | 1017 | 
                    token对应视频id错误 | 
                
                
                    | 1018 | 
                    来源地址错误 | 
                
                
                    | 2010 | 
                    来源地址错误 | 
                
                
                    | 2011 | 
                    点播失败 | 
                
                
                    | 2013 | 
                    参数不正确 | 
                
                
                    | 2015 | 
                    应用appid或key值错误 | 
                
                
            
         
        5. 技术支持
        接口开发技术支持QQ群:114918270