forked from GoChartingAdmin/client-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
30 lines (22 loc) · 684 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package main
import (
"fmt"
websocket "github.com/gorilla/websocket"
)
const APIKEY = "YOUR_API_KEY"
const CHANNELS = "C.AUD/USD,C.USD/EUR,C.USD/JPY"
func main(){
c, _, err := websocket.DefaultDialer.Dial("wss://socket.polygon.io/forex", nil ); if err != nil {
panic( err )
}
defer c.Close()
_ = c.WriteMessage( websocket.TextMessage, []byte( fmt.Sprintf("{\"action\":\"auth\",\"params\":\"%s\"}", APIKEY) ) )
_ = c.WriteMessage( websocket.TextMessage, []byte( fmt.Sprintf("{\"action\":\"subscribe\",\"params\":\"%s\"}", CHANNELS) ) )
var msg interface{}
for {
err := c.ReadJSON( &msg ); if err != nil {
panic( err )
}
fmt.Println( "Message:", msg )
}
}