Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/meowgorithm/go-kik
Go bindings for the Kik API
https://github.com/meowgorithm/go-kik
golang kik
Last synced: 6 days ago
JSON representation
Go bindings for the Kik API
- Host: GitHub
- URL: https://github.com/meowgorithm/go-kik
- Owner: meowgorithm
- Created: 2016-04-18T13:48:31.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-05-30T11:57:38.000Z (over 7 years ago)
- Last Synced: 2024-10-31T11:41:36.024Z (about 2 months ago)
- Topics: golang, kik
- Language: Go
- Homepage:
- Size: 9.77 KB
- Stars: 2
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Go Kik
Bindings for the Kik API. No external dependencies.
## Installation
go get github.com/meowgorithm/go-kik
## Overview
Kik operates over a send-receive system utilizing REST calls for sending and a
webhook for receiving. Note that SSL is required on the webhook end.For local development you could use something like [Localtunnel][lt] to expose
your development machine over SSL.[lt]: http://localtunnel.me/
## Quick Example
```go
package mainimport (
"kik"
"log"
"net/http"
)var (
client *kik.Client
webhookUrl string // public-facing URL
)func main() {
// Client for making API requests
client = &kik.Client{
Username: "username",
ApiKey: "api-key",
Callback: handleMessages,
Verbose: true,
}// Check Kik config
if _, err := client.GetConfig(), err != nil {
log.Printf("Error reading config: %s", err)
}// Set Kik config
config := kik.Config{
Callback: &webhookUrl,
Features: kik.Features{
ReceiveReadReceipts: false,
ReceiveIsTyping: false,
ManuallySendReadReceipts: false,
ReceiveDeliveryReceipts: false,
},
}
if err := client.SetConfig(config); err != nil {
log.Printf("Error setting config: %s\n", err)
}// Incoming webhook handler for Kik
http.HandleFunc("/", client.Webhook)
http.ListenAndServe(":8000", nil)
}// Handle incoming messages
func handleMessages(p kik.Payload, err error) {
// Custom keyboard
k := []kik.Keyboard{
kik.Keyboard{
Hidden: false,
Type: kik.Suggested,
Responses: []kik.KeyboardResponse{
kik.KeyboardResponse{
Type: kik.Text,
Body: "What a Button",
},
},
},
}// Reply to incoming messages
var m []kik.Message
for _, in := range p.Messages {
out := Message{
ChatId: in.ChatId,
To: in.From,
Body: "Hello world!",
Keyboards: k
}
m = append(m, out)
}// Send messages
client.SendMessages(m)
}
```## Author
Christian Rocha