I have used the link of "https://streaming-graph.facebook.com/%7Blive-video-id%7D/live_comments?access_token=%7Baccess-token%7D" to get live comments ,but the responce backs me 404 code and message is Response{protocol=h2, code=404, message=, url=https://m.facebook.com/melivevideoid/live_comments?access_token=metoken.
how can I solve the problem?
I just use the sample of facebook live comments ,and I am developing for Android Okhttp sse,so what can I do?
Sample code:
class SSEClient : EventSourceListener() {
private val TAG = "LiveVideosEventSource"
private var eventSource:EventSource? = null
fun start(liveVideoId: String, targetToken: String) {
val request = Request.Builder()
.url("https://streaming-graph.facebook.com/$liveVideoId/live_comments?access_token=$targetToken")
.header("Accept", "application/json")
.addHeader("Accept", "text/event-stream")
.build()
val client = OkHttpClient
.Builder()
.callTimeout(2, TimeUnit.MINUTES)
.readTimeout(2, TimeUnit.MINUTES)
.build()
eventSource = EventSources.createFactory(client).newEventSource(request,this)
}
fun stop() {
Log.d(TAG, "stop: ")
eventSource?.cancel()
eventSource = null
}
override fun onOpen(eventSource: EventSource, response: Response) {
super.onOpen(eventSource, response)
Log.d(TAG, "onOpen: ")
totalTime = 20
toast("start live video comments")
}
override fun onEvent(eventSource: EventSource, id: String?, type: String?, data: String) {
super.onEvent(eventSource, id, type, data)
Log.d(TAG, "onEvent: $data")
}
override fun onClosed(eventSource: EventSource) {
super.onClosed(eventSource)
Log.d(TAG, "onClosed: ")
totalTime = 20
stop()
}
override fun onFailure(eventSource: EventSource, t: Throwable?, response: Response?) {
super.onFailure(eventSource, t, response)
Log.d(TAG, "onFailure: t $t response $response")
}
}
You need to sign in to view this answers