Skip to content

Instantly share code, notes, and snippets.

@aikyo02
Created September 5, 2018 04:31
Show Gist options
  • Save aikyo02/16ace5843f2167a6503d64299dee6485 to your computer and use it in GitHub Desktop.
Save aikyo02/16ace5843f2167a6503d64299dee6485 to your computer and use it in GitHub Desktop.
package idobata_client
import "net/http"
import "net/url"
import "fmt"
const WEBHOOK_URL = "https://idobata.io/hook/custom/1f0794ab-dde4-4255-a750-0d7aa7e12714"
func PostByWebhook(message string) {
req_body := url.Values{}
req_body.Add("source", message)
_, err := http.PostForm(WEBHOOK_URL, req_body)
if err != nil {
fmt.Println(err)
}
}
const BOT_TOKEN = "xxxxxxxx"
const END_POINT = "https://api.idobata.io/graphql"
func PostByAPI(message string) {
req_body := url.Values{}
// WIP
// req_body.Add("mutation", message)
// req_body.Add("mutation", "")
req, err := http.NewRequest("POST", END_POINT, bytes.NewBuffer([]byte(req_body)))
req.Header.Add("Content-Type", "application/json")
req.Header.Add("Authorization", "Bearer " + BOT_TOKEN)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment