使用人数:123人
获取壁纸一张

  1. 接口介绍:随机获取世界景点图一张(附图片和说明)
  2. 接口地址: http://open-api-life.luzhi.online/getworldimage
  3. 请求方式: GET
  4. 返回格式: JSON
  5. 请求参数说明:
    名称 必须 类型 说明
    token String 接口调用授权签名
  6. 请求示例:
    http://open-api-life.luzhi.online/getworldimage?token=***
  7. 返回参数:
    名称 类型 说明
    code int 响应码。成功为200,其余参见接口调用响应码表
    msg String 返回消息。成功返回Succeed。其余错误消息为对应错误码的提示。
    data Object 返回数据。数据类型为Json格式的Object
    data数据说明:
    image String 图片地址
    tip String 图片说明
  8. 正确返回示例:
    {
      "code": 200,
      "message": "Succeed",
      "data": {
        "image": "https://img.luzhi.online/Xiaoluzhushou/home/Original_20200928000804xaregdycyn.jpg",
        "tip": "北大西洋亚速尔群岛附近的大青鲨 (? Nuno Sa/Minden Pictures)"
      }
    }
  9. 错误返回示例:
    {
      "code": 401,
      "message": "Sign is error",
      "data": null
    }
  10. 参考代码:

    
            //using System.IO;
            //using System.Text;
            //using System.Net;
            //using System.Net.Security;
            static void Main(string[] args)
            {
                String method = "GET";
                String url = "http://open-api-life.luzhi.online/getworldimage?token=***";
                HttpWebRequest httpRequest = (HttpWebRequest)WebRequest.Create(url); 
                httpRequest.Method = method;
                try
                {
                    HttpWebResponse httpResponse = (HttpWebResponse)httpRequest.GetResponse();
                    Stream st = httpResponse.GetResponseStream();
                    StreamReader reader = new StreamReader(st, Encoding.GetEncoding("utf-8"));
                    Console.WriteLine(reader.ReadToEnd());
                    Console.WriteLine("\n");
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }
                                                 

     
         
        public static void main(String[] args) throws IOException
        { 
            String url = "http://open-api-life.luzhi.online/getworldimage?token=***";
        
            HttpClient httpClient = HttpClients.custom().build();
            HttpGet get = new HttpGet(url);
        
            HttpResponse response = httpClient.execute(get);
            HttpEntity resp_entity = response.getEntity();
            resp_entity.getContent();
        
            String resp_content = EntityUtils.toString(resp_entity,StandardCharsets.UTF_8);
        
            System.out.println(resp_content);
        } 
                                             

    
        import json, urllib
        from urllib import urlencode
    
        url = "http://*****"
        params = { 
            "token": "*************",     # 授权签名 
            "param1":"……"               # 参数1                                       
        }
        params = urlencode(params)
        f = urllib.urlopen(url, params)
        content = f.read()
        res = json.loads(content)
        if res:
            print(res)
        else:
            print("请求异常")