package main import ( "bytes" "federated.computer/wp-sync-slowtwitch/utilities" "fmt" "io" "net/http" ) const baseUrl = "https://go-api-playground.local/wp-json/wp/v2/" const wordpressKey = "admin" const wordpressSecret = "S34E keY1 A1uX 6ncs Rx4T f21W" var appCache AppCache func main() { //Get category and cache //Get single category from cache by name //Get photo and cache with URL //Create Category (with parent) + add to cache //Upload Photo + add to cache //Use cached data to correctly build post form submissions resp, err := http.Get("https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjjPm2ryEM65R2LDKe1ov_2ThSg1Po44Pe6ybLGa9hEeKU9qLptSeYVc_ahRzA3ZiKqm73fdgYGCq2ZsfJTLPKjfCqkNtKF6xYwYfRTje3o2jH9VEKSvLyWZwCctQGHC7zREUBnJFZlI0A/s1600/Dogs+Puppies+Background+wallpaper+%25284%2529.jpg") utilities.CheckError(err) defer utilities.CloseBodyAndCheckError(resp.Body) body, err := io.ReadAll(resp.Body) utilities.CheckError(err) request, err := http.NewRequest("POST", "https://go-api-playground.local/wp-json/wp/v2/media", bytes.NewReader(body)) request.Header.Set("Content-Disposition", `attachment;filename="Dogs+Puppies+Background+wallpaper+%25284%2529.jpg"`) request.SetBasicAuth(wordpressKey, wordpressSecret) rsp, err := http.DefaultClient.Do(request) utilities.CheckError(err) result, err := io.ReadAll(rsp.Body) utilities.CheckError(err) fmt.Println(rsp.StatusCode, string(result)) }