api_blockchain.go 505 B

1234567891011121314151617181920212223242526272829303132
  1. package api
  2. import (
  3. "bytes"
  4. "io/ioutil"
  5. "net/http"
  6. )
  7. func HttpTest() (string, error) {
  8. jsonDataStr := `
  9. {
  10. "auth": {
  11. "auth": "9d8b7074bf189dcad17189c8f264c0cb",
  12. "timestamp": "123123"
  13. }
  14. }
  15. `
  16. jsonData := []byte(jsonDataStr)
  17. resp, err := http.Post("http://web.410eth.com:8888", "application/json", bytes.NewBuffer(jsonData))
  18. if err != nil {
  19. return "", err
  20. }
  21. defer resp.Body.Close()
  22. body, err := ioutil.ReadAll(resp.Body)
  23. if err != nil {
  24. return "", err
  25. }
  26. return string(body), nil
  27. }