package main

import (
    "bytes"
    "fmt"
    "io"
    "net/http"
)

func main() {
    jsonStr := []byte(`{ "username": "auto", "password": "auto123123" }`)
    url := "https://www.denlery.top/api/v1/login"
    req, err := http.NewRequest("POST", url, bytes.NewBuffer(jsonStr))
    req.Header.Set("Content-Type", "application/json")

    client := &http.Client{}
    resp, err := client.Do(req)
    if err != nil {
        // handle error
    }
    defer resp.Body.Close()
    statuscode := resp.StatusCode
    hea := resp.Header
    body, _ := io.ReadAll(resp.Body)
    fmt.Println(string(body))
    fmt.Println(statuscode)
    fmt.Println(hea)
}

func httpGet() {
    url := "https://pro-backend.99tv.ai/v1/overseas/admin/template/getTemplateInfoById?link_id="
    resp, err := http.Get(url)
    if err != nil {
        fmt.Println(err)
        return
    }
    defer resp.Body.Close()
    _, err = io.ReadAll(resp.Body)
    if resp.StatusCode == 200 {

    }
}

goper
413 声望25 粉丝

go 后端开发