I want to retrieve facebook live comments in real time. I have read this documentation This is my implementation:
func getLiveComments(liveId, token string) {
url := fmt.Sprintf("https://streaming-graph.facebook.com/%s/live_comments?access_token=%s&comment_rate=one_per_two_seconds&fields=from{name,id},message",
liveId, url.QueryEscape(token))
resp, err := http.Get(url)
if err != nil {
fmt.Printf("Get: %s
", err)
return
}
defer resp.Body.Close()
reader := bufio.NewReader(resp.Body)
for {
// got stuck here
line, err := reader.ReadBytes('
')
if err != nil {
break
}
log.Println(string(line))
}
}
But it got stuck at line, err := reader.ReadBytes(' ')
. I can use the liveId
and token
to get comments from facebook Graph API