diff --git a/drivel.go b/drivel.go index ed6aeb9..a137e65 100644 --- a/drivel.go +++ b/drivel.go @@ -49,14 +49,14 @@ func checkUsage(args []string, argcMin int, argcMax int, help string) { } func get(url string) []byte { - return _send(url, nil, false) + return send(url, nil, false) } -func send(url string, vals url.Values) []byte { - return _send(url, vals, true) +func post(url string, vals url.Values) []byte { + return send(url, vals, true) } -func _send(url string, vals url.Values, usePost bool) []byte { +func send(url string, vals url.Values, usePost bool) []byte { log := func(err error) { v, _ := json.Marshal(vals) optLogFatal("get/post "+url+" "+string(v), err) @@ -144,7 +144,7 @@ func splitArguments(args []string) data { func tweet(status string, mediaIDs []ObjectID, previousID ObjectID) Status { log := func(err error) { optLogFatal("tweet "+status, err) } request := UpdateStatusRequest(status, mediaIDs, previousID) - body := send(STATUS_ENDPOINT, request) + body := post(STATUS_ENDPOINT, request) var tweet Status err := json.Unmarshal(body, &tweet) log(err) @@ -396,7 +396,7 @@ func retweet(args []string) error { if len(tweets) != 1 { log(errors.New("Could not find tweet " + id)) } - body := send(RETWEET_ENDPOINT+RetweetParameters(id), nil) + body := post(RETWEET_ENDPOINT+RetweetParameters(id), nil) var retweet Status err := json.Unmarshal(body, &retweet) log(err) @@ -407,7 +407,7 @@ func retweet(args []string) error { func like(args []string) error { checkUsage(args, 1, 1, "like TWEET_ID") log := func(err error) { optLogFatal("like", err) } - body := send(LIKE_ENDPOINT, LikeRequest(args[0])) + body := post(LIKE_ENDPOINT, LikeRequest(args[0])) var tweet Status err := json.Unmarshal(body, &tweet) log(err) @@ -417,7 +417,7 @@ func like(args []string) error { func unlike(id string) { log := func(err error) { optLogFatal("unlike", err) } - body := send(DESTROY_LIKE_ENDPOINT, UnlikeRequest(id)) + body := post(DESTROY_LIKE_ENDPOINT, UnlikeRequest(id)) var tweet Status err := json.Unmarshal(body, &tweet) log(err) @@ -426,7 +426,7 @@ func unlike(id string) { func destroyStatus(id string) { log := func(err error) { optLogFatal("destroy", err) } - body := send(DESTROY_STATUS_ENDPOINT+DestroyParameters(id), nil) + body := post(DESTROY_STATUS_ENDPOINT+DestroyParameters(id), nil) var tweet Status err := json.Unmarshal(body, &tweet) log(err) diff --git a/media.go b/media.go index fef28ae..bc0617c 100644 --- a/media.go +++ b/media.go @@ -102,7 +102,7 @@ func getMimetype(file string) string { func initFileUpload(file string, mediaData []byte) ObjectID { log := func(err error) { optLogFatal("initFileUpload "+file, err) } initRequest := InitRequest(getMimetype(file), len(mediaData)) - body := send(UPLOAD_ENDPOINT, initRequest) + body := post(UPLOAD_ENDPOINT, initRequest) var initResponse InitResponse err := json.Unmarshal(body, &initResponse) log(err) @@ -130,7 +130,7 @@ func appendFileChunks(file string, media string, mediaId ObjectID) { var body []byte for try := 0; try < 3 && !appended; try++ { appRequest := AppendRequest(mediaId, media[start:end], i) - body = send(UPLOAD_ENDPOINT, appRequest) + body = post(UPLOAD_ENDPOINT, appRequest) if string(body) == "" { appended = true } @@ -143,7 +143,7 @@ func appendFileChunks(file string, media string, mediaId ObjectID) { func finalizeFileUpload(file string, mediaId ObjectID) int64 { log := func(err error) { optLogFatal("finalizeFileUpload", err) } - body := send(UPLOAD_ENDPOINT, FinalizeRequest(mediaId)) + body := post(UPLOAD_ENDPOINT, FinalizeRequest(mediaId)) var finalizeResponse FinalizeResponse err := json.Unmarshal(body, &finalizeResponse) log(err)