Created
September 1, 2020 17:15
-
-
Save codenuke/f61faeead0280f7a3d3fced75d41cb41 to your computer and use it in GitHub Desktop.
go-line-notify.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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