From 63108f50ce82c870b397df31f1485b9765d3399c Mon Sep 17 00:00:00 2001 From: Linas Jakucionis Date: Sat, 16 Jul 2016 13:56:25 +1200 Subject: [PATCH 1/4] Update README.md Fixed the example and added links to the plugins --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index f9478d2..4fafd95 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ func main() { }) // for eg, to get current user (GET /users/me) - currentUser, resp, body, _ := client.Users().Me() + currentUser, resp, body, _ := client.Users().Me(nil) if resp.StatusCode != http.StatusOK { // handle error } @@ -59,9 +59,9 @@ Before running the tests, ensure that you have set up your test environment ### Prerequisites - Wordpress 4.x -- WP-API plugin -- WP-API's BasicAuth plugin (for authentication) -- [WP REST API Meta Endpoints plugin](https://github.com/WP-API/wp-api-meta-endpoints) (for Meta endpoints) +- [WP-API plugin](https://wordpress.org/plugins/rest-api/) +- [WP-API's BasicAuth plugin](https://github.com/WP-API/Basic-Auth) (for authentication) - I was unable to find it this plugin published anywhere outside of github. But it was easy to just choose Clone or Download -> Download ZIP. After that the downloaded ZIP can be treated as a standard plugin and just installed in WordPress via upload. +- [WP REST API Meta Endpoints plugin](https://github.com/WP-API/wp-api-meta-endpoints) (for Meta endpoints) - This can be installed through standard WordPress plugin directory [here](https://wordpress.org/plugins/rest-api-meta-endpoints/) ### Setting up test environment - Install prequisits (see above) From 4758c926ed020a4804fea6f3f5b14a7767dadf10 Mon Sep 17 00:00:00 2001 From: Linas Jakucionis Date: Sat, 16 Jul 2016 13:59:12 +1200 Subject: [PATCH 2/4] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4fafd95..2d49d83 100644 --- a/README.md +++ b/README.md @@ -60,7 +60,7 @@ Before running the tests, ensure that you have set up your test environment ### Prerequisites - Wordpress 4.x - [WP-API plugin](https://wordpress.org/plugins/rest-api/) -- [WP-API's BasicAuth plugin](https://github.com/WP-API/Basic-Auth) (for authentication) - I was unable to find it this plugin published anywhere outside of github. But it was easy to just choose Clone or Download -> Download ZIP. After that the downloaded ZIP can be treated as a standard plugin and just installed in WordPress via upload. +- [WP-API's BasicAuth plugin](https://github.com/WP-API/Basic-Auth) (for authentication) - I was unable to find this plugin published anywhere outside of github. But it was easy to just choose Clone or Download -> Download ZIP. After that the downloaded ZIP can be treated as a standard plugin and just installed in WordPress via upload. - [WP REST API Meta Endpoints plugin](https://github.com/WP-API/wp-api-meta-endpoints) (for Meta endpoints) - This can be installed through standard WordPress plugin directory [here](https://wordpress.org/plugins/rest-api-meta-endpoints/) ### Setting up test environment From 7fe1cc79de1e31184453baf49a271f0b72779013 Mon Sep 17 00:00:00 2001 From: Linas Jakucionis Date: Sat, 16 Jul 2016 17:21:50 +1200 Subject: [PATCH 3/4] Fix upload of media. WordPress and/or Apache were complaining about the Content-Disposition header being malformed. Fix setting the FeaturedImage for a post. According to http://v2.wp-api.org/reference/posts/ it's supposed json attribute is "featured_media" not "featured_image" --- client.go | 2 +- posts.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/client.go b/client.go index e1163ad..66f5cb4 100644 --- a/client.go +++ b/client.go @@ -201,7 +201,7 @@ func (client *Client) PostData(url string, content []byte, contentType string, f } req.Header.Set("Content-Type", contentType) - req.Header.Set("Content-Disposition", fmt.Sprintf("filename=%v", filename)) + req.Header.Set("Content-Disposition", fmt.Sprintf("attachment; filename=\"%v\"", filename)) // Add basic auth req.SetBasicAuth(s.BasicAuth.Username, s.BasicAuth.Password) diff --git a/posts.go b/posts.go index e082b7a..744a5af 100644 --- a/posts.go +++ b/posts.go @@ -70,7 +70,7 @@ type Post struct { Content Content `json:"content,omitempty"` Author int `json:"author,omitempty"` Excerpt Excerpt `json:"excerpt,omitempty"` - FeaturedImage int `json:"featured_image,omitempty"` + FeaturedImage int `json:"featured_media,omitempty"` CommentStatus string `json:"comment_status,omitempty"` PingStatus string `json:"ping_status,omitempty"` Format string `json:"format,omitempty"` From 4a771448de08d1ca6de19beb957e472eca3eebb8 Mon Sep 17 00:00:00 2001 From: Linas Jakucionis Date: Sun, 31 Jul 2016 19:11:25 +1200 Subject: [PATCH 4/4] Added support for categories --- posts.go | 1 + 1 file changed, 1 insertion(+) diff --git a/posts.go b/posts.go index 744a5af..67c07aa 100644 --- a/posts.go +++ b/posts.go @@ -75,6 +75,7 @@ type Post struct { PingStatus string `json:"ping_status,omitempty"` Format string `json:"format,omitempty"` Sticky bool `json:"sticky,omitempty"` + Categories []int `json:"categories,omitempty"` } func (entity *Post) setCollection(col *PostsCollection) {