2024-05-07 22:03:15 +00:00
|
|
|
package wordpress
|
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/json"
|
|
|
|
"federated.computer/wp-sync-slowtwitch/utilities"
|
|
|
|
)
|
|
|
|
|
|
|
|
type PostData struct {
|
|
|
|
Id int `json:"id"`
|
|
|
|
Link string `json:"link"`
|
|
|
|
Title struct {
|
|
|
|
Rendered string `json:"rendered"`
|
|
|
|
} `json:"title"`
|
|
|
|
Content struct {
|
|
|
|
Rendered string `json:"rendered"`
|
|
|
|
} `json:"content"`
|
|
|
|
AuthorId int `json:"author"`
|
|
|
|
Excerpt struct {
|
|
|
|
Rendered string `json:"rendered"`
|
|
|
|
} `json:"excerpt"`
|
|
|
|
FeaturedMediaId int `json:"featured_media"`
|
|
|
|
}
|
|
|
|
|
2024-05-07 22:21:52 +00:00
|
|
|
func GetPosts(baseUrl, user, pass string) []PostData {
|
|
|
|
url := baseUrl + "posts?per_page=99"
|
|
|
|
body := utilities.GetHttpRequestToWordpress(url, user, pass)
|
2024-05-07 22:03:15 +00:00
|
|
|
var posts []PostData
|
2024-05-07 22:21:52 +00:00
|
|
|
err := json.Unmarshal(body, &posts)
|
2024-05-07 22:03:15 +00:00
|
|
|
utilities.CheckError(err)
|
|
|
|
return posts
|
|
|
|
}
|