// SharePost is the primary method of sharing a post.
SharePost is the primary method of sharing a post.
// SharePost is the primary method of sharing a post .
func SharePost(post *Post, w http.ResponseWriter, r *http.Request) (*http.Response, error) {
	if validState(r) == false {
		err := fmt.Errorf("state comparison failed")
		return &http.Response{}, err
	}
	params := r.URL.Query()
	tok, err := authConf.Exchange(oauth2.NoContext, params.Get("code"))
	if err != nil {
		return &http.Response{}, err
	}
	client := authConf.Client(oauth2.NoContext, tok)
	data := postToJSON(post)
	resp, err := client.Post(postURL, "application/json", bytes.NewReader(data))
	if err != nil {
		return &http.Response{}, err
	}
	if resp.StatusCode == 400 {
		err = fmt.Errorf("cannot post duplicate content")
	}
	if resp.StatusCode == 201 {
		return resp, nil
	}
	err = fmt.Errorf("post unsuccessful, response given: %v", resp)
	return &http.Response{}, err
}
func SharePost ( post * Post , w http . ResponseWriter , r * http . Request ) ( * http . Response , error ) { if validState ( r ) == false { err := fmt . Errorf ( " " ) return & http . Response { } , err } params := r . URL . Query ( ) tok , err := authConf . Exchange ( oauth2 . NoContext , params . Get ( " " ) ) if err != nil { return & http . Response { } , err } client := authConf . Client ( oauth2 . NoContext , tok ) data := postToJSON ( post ) resp , err := client . Post ( postURL , " " , bytes . NewReader ( data ) ) if err != nil { return & http . Response { } , err } if resp . StatusCode == 400 { err = fmt . Errorf ( " " ) } if resp . StatusCode == 201 { return resp , nil } err = fmt . Errorf ( " " , resp ) return & http . Response { } , err }
SharePost is the primary method of sharing a post.
SharePost is the primary method of sharing a post .
// Authenticate // Upload Data