Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ package wordpress
import (
"bytes"
"fmt"
"github.com/parnurzeal/gorequest"
"io/ioutil"
"log"
"net/http"
"reflect"

"github.com/parnurzeal/gorequest"
)

const (
Expand Down Expand Up @@ -111,7 +112,7 @@ func (client *Client) Taxonomies() *TaxonomiesCollection {
func (client *Client) Terms() *TermsCollection {
return &TermsCollection{
client: client,
url: fmt.Sprintf("%v/%v", client.baseURL, CollectionTerms),
url: fmt.Sprintf("%v", client.baseURL),
}
}
func (client *Client) Statuses() *StatusesCollection {
Expand Down Expand Up @@ -141,7 +142,9 @@ func (client *Client) Create(url string, content interface{}, result interface{}
contentVal := unpackInterfacePointer(content)
client.req.TargetType = "json"
req := client.req.Post(url).Send(contentVal)
fmt.Printf("\n\n\n%+v\n\n\n", req)
resp, body, errSlice := req.EndBytes()
fmt.Printf("\n\n\n%+v\n\n\n", resp)
if errSlice != nil && len(errSlice) > 0 {
return nil, body, errSlice[len(errSlice)-1]
}
Expand Down Expand Up @@ -201,7 +204,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)
Expand Down
4 changes: 3 additions & 1 deletion posts.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,13 @@ 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"`
Sticky bool `json:"sticky,omitempty"`
Categories []int `json:"categories,omitempty"`
Tags []int `json:"tags,omitempty"`
}

func (entity *Post) setCollection(col *PostsCollection) {
Expand Down
2 changes: 1 addition & 1 deletion terms.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func (col *TermsCollection) List(taxonomy string, params interface{}) ([]Term, *
func (col *TermsCollection) Tag() *TermsTaxonomyCollection {
return &TermsTaxonomyCollection{
client: col.client,
url: fmt.Sprintf("%v/tag", col.url),
url: fmt.Sprintf("%v/tags", col.url),
taxonomyBase: "tag",
}
}
Expand Down