32 lines
707 B
Go
32 lines
707 B
Go
package main
|
|
|
|
import (
|
|
"errors"
|
|
"local/oauth2"
|
|
"log"
|
|
"net/http"
|
|
"net/url"
|
|
"strings"
|
|
"time"
|
|
)
|
|
|
|
func Upload(config Config, transaction *Transaction) error {
|
|
params := url.Values{
|
|
"list": {"2548023766"},
|
|
"title": {"test task: " + time.Now().String()},
|
|
"tag": {"expense"},
|
|
}
|
|
req, err := http.NewRequest("POST", config.TodoAddr+"/ajax.php?newTask", strings.NewReader(params.Encode()))
|
|
if err != nil {
|
|
return err
|
|
}
|
|
req.Header.Set("Cookie", oauth2.COOKIE+"="+config.TodoToken)
|
|
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
|
|
resp, err := http.DefaultClient.Do(req)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
log.Printf("%+v\n\n%+v", req, resp)
|
|
return errors.New("not impl")
|
|
}
|