zoukankan      html  css  js  c++  java
  • scala获取接口中的数据

    代码如下:

    //需要传入的某个参数是个数组
    val set = new mutable.HashSet[Long]()
    set.add(40929354653L)
    set.add(611771548884L)
    val arr = set.toArray
    //把参数转换成json格式
    val jsonObj = new JSONObject
    jsonObj.put("streamerId", 5) //参数1
    jsonObj.put("payStart", 1605186600000L) //参数2
    jsonObj.put("payEnd", 1605194760000L) //参数3
    jsonObj.put("itemIds", arr) //参数4
    try {
      val body = Http("https://接口地址")
        .postData(jsonObj.toJSONString)
        .header("Content-Type", "application/json")
        .header("Charset", "UTF-8")
        .options(HttpOptions.readTimeout(100000)).asString.body
      println(s"==========body: $body==========")
    } catch {
      case e: Exception => {
        println(e)
      }
    }
  • 相关阅读:
    球自由降落问题
    三次握手、四次挥手
    basicjava
    socket编程
    scanner和BufferedReader
    parseInt和valueOf
    正则表达式
    ASCII码常用值
    最大公约和最小公倍数
    查询语句
  • 原文地址:https://www.cnblogs.com/atBruce/p/13964862.html
Copyright © 2011-2022 走看看