Skip to content

Instantly share code, notes, and snippets.

@codenuke
Created September 1, 2020 17:15
Show Gist options
  • Save codenuke/f61faeead0280f7a3d3fced75d41cb41 to your computer and use it in GitHub Desktop.
Save codenuke/f61faeead0280f7a3d3fced75d41cb41 to your computer and use it in GitHub Desktop.
go-line-notify.go
package main
import (
"crypto/tls"
"fmt"
"net/http"
"net/url"
"strconv"
"strings"
)
func main() {
// Create form value
token := "xxxx"
data := url.Values{}
data.Set("message", "Hello")
// ignore ssl
http.DefaultTransport.(*http.Transport).TLSClientConfig = &tls.Config{InsecureSkipVerify: true}
client := &http.Client{}
r, _ := http.NewRequest("POST", "https://notify-api.line.me/api/notify", strings.NewReader(data.Encode()))
r.Header.Add("Content-Type", "application/x-www-form-urlencoded")
r.Header.Add("Authorization", "Bearer "+token)
r.Header.Add("Content-Length", strconv.Itoa(len(data.Encode())))
resp, err := client.Do(r)
defer resp.Body.Close()
if err != nil {
fmt.Println(err)
}
fmt.Println(resp)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment