Compare commits
No commits in common. "1d2ea468b60e08f1ee50e88abe3a4317c8d797cb" and "e943c10c2b386a06929515e6d34ad41d356be4f8" have entirely different histories.
1d2ea468b6
...
e943c10c2b
2 changed files with 7 additions and 18 deletions
1
main.go
1
main.go
|
@ -182,6 +182,7 @@ func main() {
|
||||||
http.HandleFunc("/copiar", func(w http.ResponseWriter, r *http.Request) {
|
http.HandleFunc("/copiar", func(w http.ResponseWriter, r *http.Request) {
|
||||||
asset, err := getRandomOpenSeaAsset()
|
asset, err := getRandomOpenSeaAsset()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Println("Error hablandole a OpenSea:", err)
|
||||||
internalError(w, "Error hablandole a OpenSea.")
|
internalError(w, "Error hablandole a OpenSea.")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
20
opensea.go
20
opensea.go
|
@ -2,8 +2,6 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"io/ioutil"
|
|
||||||
"log"
|
|
||||||
"math"
|
"math"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
@ -59,25 +57,15 @@ func GetAssets() (Assets, error) {
|
||||||
} `json:"assets"`
|
} `json:"assets"`
|
||||||
}{}
|
}{}
|
||||||
assets := Assets{}
|
assets := Assets{}
|
||||||
req, err := http.NewRequest("GET", "https://api.opensea.io/api/v1/assets"+
|
res, err := http.DefaultClient.Get("https://api.opensea.io/api/v1/assets" +
|
||||||
"?order_direction=desc" +
|
"?order_direction=desc" +
|
||||||
"&offset=0" +
|
"&offset=0" +
|
||||||
"&limit=20"+
|
"&limit=50" +
|
||||||
"&order_by=sale_date", nil)
|
"&order_by=sale_date")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return assets, err
|
return assets, err
|
||||||
}
|
}
|
||||||
req.Header.Set("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36")
|
err = json.NewDecoder(res.Body).Decode(&parsed)
|
||||||
res, err := http.DefaultClient.Do(req)
|
|
||||||
if err != nil {
|
|
||||||
return assets, err
|
|
||||||
}
|
|
||||||
bytes, err := ioutil.ReadAll(res.Body)
|
|
||||||
log.Println(string(bytes))
|
|
||||||
if err != nil {
|
|
||||||
return assets, err
|
|
||||||
}
|
|
||||||
err = json.Unmarshal(bytes, &parsed)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return assets, err
|
return assets, err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue