simplepaste.go
func (api * API) SendPaste(paste Paste) (string, error) {
	if paste.UserKey == "" && paste.Privacy == "2" {
		return "", PrivacyModError
	}
	values := url.Values{}
	values.Set("api_dev_key", api.APIKey)
	values.Set("api_user_key", paste.UserKey)
	values.Set("api_option", "paste")
	values.Set("api_paste_code", paste.Text)
	values.Set("api_paste_name", paste.Name)
	values.Set("api_paste_private", paste.Privacy)
	values.Set("api_paste_expire_date", paste.ExpireDate)
	response, err := http.PostForm("http://pastebin.com/api/api_post.php", values)
	defer response.Body.Close()
	if err != nil {
		return "", err
	}
	if response.StatusCode != 200 {
		return "", PastePostingError
	}
	buf := bytes.Buffer{}
	_, err = buf.ReadFrom(response.Body)
	if err != nil {
		return "", err
	}
	return buf.String(), nil
}
func (api * API) SendPaste(paste Paste) (string, error) {
	if paste.UserKey == "" && paste.Privacy == "2" {
		return "", PrivacyModError
	}
	values := url.Values{}
	values.Set("api_dev_key", api.APIKey)
	values.Set("api_user_key", paste.UserKey)
	values.Set("api_option", "paste")
	values.Set("api_paste_code", paste.Text)
	values.Set("api_paste_name", paste.Name)
	values.Set("api_paste_private", paste.Privacy)
	values.Set("api_paste_expire_date", paste.ExpireDate)
	response, err := http.PostForm("http://pastebin.com/api/api_post.php", values)
	defer response.Body.Close()
	if err != nil {
		return "", err
	}
	if response.StatusCode != 200 {
		return "", PastePostingError
	}
	buf := bytes.Buffer{}
	_, err = buf.ReadFrom(response.Body)
	if err != nil {
		return "", err
	}
	return buf.String(), nil
}
func ( api * API ) SendPaste ( paste Paste ) ( string , error ) { if paste . UserKey == " " && paste . Privacy == " " { return " " , PrivacyModError } values := url . Values { } values . Set ( " " , api . APIKey ) values . Set ( " " , paste . UserKey ) values . Set ( " " , " " ) values . Set ( " " , paste . Text ) values . Set ( " " , paste . Name ) values . Set ( " " , paste . Privacy ) values . Set ( " " , paste . ExpireDate ) response , err := http . PostForm ( " " , values ) defer response . Body . Close ( ) if err != nil { return " " , err } if response . StatusCode != 200 { return " " , PastePostingError } buf := bytes . Buffer { } _ , err = buf . ReadFrom ( response . Body ) if err != nil { return " " , err } return buf . String ( ) , nil }
//Returns paste link string and nil if everything is ok
Returns paste link string and nil if everything is ok