**WORK IN PROGRESS** golang API client for interacting with the jschan imageboard API.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

50 lines
917 B

package jschan
import (
"context"
"fmt"
"net/http"
"net/url"
"strings"
)
type PostMakePostOptions struct {
Board string
Thread int
Name string
Message string
Subject string
Email string
PostPassword string
//TODO: Files
Spoiler []string
SpoilerAll bool
StripFilename []string
CustomFlag string
//Array for grid captcha, submitted as single param if len()==1
Captcha []string
}
func (c *Client) MakePost(ctx context.Context, options *PostMakePostOptions) error {
formData := url.Values{}
//TODO: post params
endodedBody := strings.NewReader(formData.Encode())
url := fmt.Sprintf("%s/forms/%s/post", c.BaseURL, options.Board)
req, err := http.NewRequest(http.MethodPost, url, endodedBody)
if err != nil {
return err
}
req = req.WithContext(ctx)
if err := c.sendRequest(req, nil, nil); err != nil {
return err
}
return nil
}