Interacting with Viewers

You can use the Live Video API to get comments and reactions on live video broadcasts so that video producers and on-air talent can interact with viewers. You can do this by periodically querying the LiveVideo object to get current comments and reactions, or set up Server-Sent Events to receive real-time comments and reactions.

Getting Current Comments and Reactions

To get the current comments or reactions on a live video broadcast, send a request to:

GET /{live-video-id}/comments
GET /{live-video-id}/reactions

Sample Request

curl -i -X GET \
  "https://graph.facebook.com/{live-video-id}/comments?access_token={access-token}"
GraphRequest request = GraphRequest.newGraphPathRequest(
  accessToken,
  "/{live-video-id}/comments",
  new GraphRequest.Callback() {
    @Override
    public void onCompleted(GraphResponse response) {
      // Insert your code here
    }
});

request.executeAsync();
FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc]
    initWithGraphPath:@"/{live-video-id}/comments"
           parameters:nil
           HTTPMethod:@"GET"];
[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
    // Insert your code here
}];
FB.api(
  '/{live-video-id}/comments',
  'GET',
  {},
  function(response) {
      // Insert your code here
  }
);
try {
  // Returns a `FacebookFacebookResponse` object
  $response = $fb->get(
    '/{live-video-id}/comments',
    '{access-token}'
  );
} catch(FacebookExceptionsFacebookResponseException $e) {
  echo 'Graph returned an error: ' . $e->getMessage();
  exit;
} catch(FacebookExceptionsFacebookSDKException $e) {
  echo 'Facebook SDK returned an error: ' . $e->getMessage();
  exit;
}
$graphNode = $response->getGraphNode();

Sample Response

{
  "data": [
    {
      "created_time": "2018-08-30T18:47:02+0000",
      "from": {
        "name": "Steph C.",
        "id": "552524095105158"
      },
      "message": "This is such a great live stream.",
      "id": "911936075671494_911936769004758"
    },
    {
      "created_time": "2018-08-30T18:47:17+0000",
      "from": {
        "name": "Kevin D.",
        "id": "552524095105158"
      },
      "message": "Shoutout over here!",
      "id": "911936075671494_911936909004744"
    },
    {
      "created_time": "2018-08-30T18:48:14+0000",
      "from": {
        "name": "Clay T.",
        "id": "552524095105158"
      },
      "message": "Where is this place?",
      "id": "911936075671494_911937292338039"
    }
    ],
  "paging": {
    "cursors": {
      "before": "WTI5d...",
      "after": "WTI5d..."
    }
  }
}

Refer to the Comments and Reactions edge references for information on returnable fields, and filtering and ordering instructions. Comments and reactions can be polled every few seconds.

Receiving Real-time Comments and Reactions

To receive comments and reactions in browser clients in real-time, set up Server Sent Events and send a request to these endpoints:

GET /{live-video-id}/live_comments
GET /{live-video-id}/live_reactions

Note that the host URL for streaming events is: https://streaming-graph.facebook.com

Sample Request

GET https://streaming-graph.facebook.com/{live-video-id}/live_comments?access_token={access-token}
var source = new EventSource("https://streaming-graph.facebook.com/{live-video-id}/live_comments?access_token={access-token}");
source.onmessage = function(event) {
  // Do something with event.message for example
};

Sample Response

: ping
data:
  {
    "created_time":"2018-08-30T21:11:01+0000",
    "id":"911936075671494_912014908996944",
    "view_id":43329028,
    "from":
      {
        "id":"552524095105158",
        "name":"Kerry Fisher"
      },
    "message":"I love this video!"
  }
: ping
: ping

Refer to the Live Comments and Live Reactions references for information on returnable fields, ping frequency, and filtering.