Live Polls API

The Live Polls API allows you to create and manage Video Polls on Live and On-Demand Videos.

Create a Poll

Edges

Requirements

TypeDescription

Features

For a VideoPoll on a Group's LiveVideo:


Permissions

For a VideoPoll on a User's LiveVideo:


For a VideoPoll on a Page's LiveVideo:


For a VideoPoll on a Group's LiveVideo:


Access Tokens

The same access token used to create the LiveVideo or Broadcast.

Examples

Send a POST request to the /id/polls edge where id is a broadcast-id or a live-video-id and set the question field to the question you want to ask and options field to the answer choices for the question.

curl -i -X POST \
  "https://graph.facebook.com/{live-video-id}/polls
    ?question=Which%20bear%20is%20best%3F 
    &options=["Brown bear", 
              "Black bear", 
              "That is a stupid question", 
              "Basically, there are two schools of thought"]
    &access_token={access-token}"
GraphRequest request = GraphRequest.newPostRequest(
  accessToken,
  "/{live-video-id}/polls",
  new JSONObject("{\"question\":\"What is the best bear?\",\"options\":\"[\"Brown bear\", \"Black bear\", \"That is a stupid question\", \"Basically, there are two schools of thought\"]\"}"),
  new GraphRequest.Callback() {
    @Override
    public void onCompleted(GraphResponse response) {
      // Insert your code here
    }
});
request.executeAsync();
FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc]
    initWithGraphPath:@"/{live-video-id}/polls"
           parameters:@{ @"question": @"What is the best bear?",@"options": @"['Brown bear', 'Black bear', 'That is a stupid question', 'Basically, there are two schools of thought']",}
           HTTPMethod:@"POST"];
[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
    // Insert your code here
}];
FB.api(
  '/{live-video-id}/polls',
  'POST',
  {"question":"What is the best bear?","options":"['Brown bear', 'Black bear', 'That is a stupid question', 'Basically, there are two schools of thought']"},
  function(response) {
      // Insert your code here
  }
);
try {
  // Returns a `FacebookFacebookResponse` object
  $response = $fb->post(
    '/{live-video-id}/polls',
    array (
      'question' => 'What is the best bear?',
      'options' => '["Brown bear", "Black bear", "That is a stupid question", "Basically, there are two schools of thought"]'
    ),
    '{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

{
  "id": "{video-poll-id}"
}

Refer to the Polls edge reference for a complete list of fields you can use when creating your poll.

Close a Poll

Closing a poll after a person has selected a poll option.

Nodes

Requirements

TypeDescription

Features

For a VideoPoll on a Group's LiveVideo:


Permissions

For a VideoPoll on a User's LiveVideo:


For a VideoPoll on a Page's LiveVideo:


For a VideoPoll on a Group's LiveVideo:


Access Tokens

The same access token used to create the LiveVideo or Broadcast.

Examples

Send a POST request to the /id node where id is the video-poll-id and set the action parameter to CLOSE.

curl -i -X POST \
 "https://graph.facebook.com/{your-video-poll-id}
   ?action=CLOSE
   &access_token={access-token}"
GraphRequest request = GraphRequest.newPostRequest(
  accessToken,
  "/{your-video-poll-id}",
  new JSONObject("{\"action\":\"CLOSE\"}"),
  new GraphRequest.Callback() {
    @Override
    public void onCompleted(GraphResponse response) {
      // Insert your code here
    }
});
request.executeAsync();
FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc]
    initWithGraphPath:@"/{your-video-poll-id}"
           parameters:@{ @"action": @"CLOSE",}
           HTTPMethod:@"POST"];
[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
    // Insert your code here
}];
FB.api(
  '/{your-video-poll-id}',
  'POST',
  {"action":"CLOSE"},
  function(response) {
      // Insert your code here
  }
);
try {
  // Returns a `FacebookFacebookResponse` object
  $response = $fb->post(
    '/{your-video-poll-id}',
    array (
      'action' => 'CLOSE'
    ),
    '{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

{
  "success": true
}

Reopen A Closed Poll

Reopen a closed poll so a person can change their poll option.

Nodes

Requirements

TypeDescription

Features

For a VideoPoll on a Group's LiveVideo:


Permissions

For a VideoPoll on a User's LiveVideo:


For a VideoPoll on a Page's LiveVideo:


For a VideoPoll on a Group's LiveVideo:


Access Tokens

The same access token used to create the LiveVideo or Broadcast.

Examples

Send a POST /id request where id is the video-poll-id and set action to SHOW_VOTING.

curl -i -X POST \
 "https://graph.facebook.com/{your-video-poll-id}
   ?action=SHOW_VOTING
   &access_token={access-token}"
GraphRequest request = GraphRequest.newPostRequest(
  accessToken,
  "/{your-video-poll-id}",
  new JSONObject("{\"action\":\"SHOW_VOTING\"}"),
  new GraphRequest.Callback() {
    @Override
    public void onCompleted(GraphResponse response) {
      // Insert your code here
    }
});
request.executeAsync();
FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc]
    initWithGraphPath:@"/{your-video-poll-id}"
           parameters:@{ @"action": @"SHOW_VOTING",}
           HTTPMethod:@"POST"];
[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
    // Insert your code here
}];
FB.api(
  '/{your-video-poll-id}',
  'POST',
  {"action":"SHOW_VOTING"},
  function(response) {
      // Insert your code here
  }
);
try {
  // Returns a `FacebookFacebookResponse` object
  $response = $fb->post(
    '/{your-video-poll-id}',
    array (
      'action' => 'SHOW_VOTING'
    ),
    '{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

{
  "success": true
}

Note: The poll will continue to use the default_open and show_results settings that were set upon poll creation.

Show Closed Poll Results

Update a poll so it displays the results to the person after they have voted.

Nodes

Requirements

TypeDescription

Features

For a VideoPoll on a Group's LiveVideo:


Permissions

For a VideoPoll on a User's LiveVideo:


For a VideoPoll on a Page's LiveVideo:


For a VideoPoll on a Group's LiveVideo:


Access Tokens

The same access token used to create the LiveVideo or Broadcast.

Examples

Send a POST /id request where id is the video-poll-id and set the action parameter to SHOW_RESULTS.

curl -i -X POST \
 "https://graph.facebook.com/{your-video-poll-id}
    ?action=SHOW_RESULTS
    &access_token={access-token}"
GraphRequest request = GraphRequest.newPostRequest(
  accessToken,
  "/{your-video-poll-id}",
  new JSONObject("{\"action\":\"SHOW_RESULTS\"}"),
  new GraphRequest.Callback() {
    @Override
    public void onCompleted(GraphResponse response) {
      // Insert your code here
    }
});
request.executeAsync();
FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc]
    initWithGraphPath:@"/{your-video-poll-id}"
           parameters:@{ @"action": @"SHOW_RESULTS",}
           HTTPMethod:@"POST"];
[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
    // Insert your code here
}];
FB.api(
  '/{your-video-poll-id}',
  'POST',
  {"action":"SHOW_RESULTS"},
  function(response) {
      // Insert your code here
  }
);
try {
  // Returns a `FacebookFacebookResponse` object
  $response = $fb->post(
    '/{your-video-poll-id}',
    array (
      'action' => 'SHOW_RESULTS'
    ),
    '{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

{
  "success": true
}

Get Poll Settings

Get poll settings such as available options, current status, or results.

Edges

Requirements

TypeDescription

Features

For a VideoPoll on a Group's LiveVideo:


Permissions

For a VideoPoll on a User's LiveVideo:


For a VideoPoll on a Page's LiveVideo:


For a VideoPoll on a Group's LiveVideo:


Access Tokens

The same access token used to create the LiveVideo or Broadcast.

Examples

Send a GET /id request where id is the video-poll-id and set fields to poll_options.

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

Bundle parameters = new Bundle();
parameters.putString("fields", "poll_options");
request.setParameters(parameters);
request.executeAsync();
FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc]
    initWithGraphPath:@"/{your-video-poll-id}"
           parameters:@{ @"fields": @"poll_options",}
           HTTPMethod:@"GET"];
[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
    // Insert your code here
}];
FB.api(
  '/{your-video-poll-id}',
  'GET',
  {"fields":"poll_options"},
  function(response) {
      // Insert your code here
  }
);
try {
  // Returns a `FacebookFacebookResponse` object
  $response = $fb->get(
    '/{your-video-poll-id}',
    '{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

{
  "poll_options":
    {
      "data": [
        {
          "text": "Brown bear",
          "id": 145049637
        },
        {
          "text": "Black bear",
          "id": 145049638
        }
        {
          "text": "That is a stupid question",
          "id": 145049639
        }
        {
          "text": "Basically, there are two schools of thought",
          "id": 145049640
        }
      ]
    },
  "id": 12345
}

Refer to the Video Poll node reference for a list of available fields.

Getting Votes for a Specific Poll Option

Edges

Requirements

TypeDescription

Features

For a VideoPoll on a Group's LiveVideo:


Permissions

For a VideoPoll on a User's LiveVideo:


For a VideoPoll on a Page's LiveVideo:


For a VideoPoll on a Group's LiveVideo:


Access Tokens

The same access token used to create the LiveVideo or Broadcast.

Examples

Send a GET /id request where id is the video-poll-option-id and set the fields to total_votes.

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

Bundle parameters = new Bundle();
parameters.putString("fields", "total_votes");
request.setParameters(parameters);
request.executeAsync();
FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc]
    initWithGraphPath:@"/{your-video-poll-option}"
           parameters:@{ @"fields": @"total_votes",}
           HTTPMethod:@"GET"];
[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
    // Insert your code here
}];
FB.api(
  '/{your-video-poll-option}',
  'GET',
  {"fields":"total_votes"},
  function(response) {
      // Insert your code here
  }
);
try {
  // Returns a `FacebookFacebookResponse` object
  $response = $fb->get(
    '/{your-video-poll-option}',
    '{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

    {
  "total_votes": 129,
  "id": "{your-video-poll-option}"
}

Getting Number of Votes for All Poll Options

Edges

Requirements

TypeDescription

Features

For a VideoPoll on a Group's LiveVideo:


Permissions

For a VideoPoll on a User's LiveVideo:


For a VideoPoll on a Page's LiveVideo:


For a VideoPoll on a Group's LiveVideo:


Access Tokens

The same access token used to create the LiveVideo or Broadcast.

Examples

Send a GET /id request where id is the video-poll-id and set the poll_options field with parameters text and total_votes.

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

Bundle parameters = new Bundle();
parameters.putString("fields", "poll_options{text,total_votes}");
request.setParameters(parameters);
request.executeAsync();
FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc]
    initWithGraphPath:@"/{your-video-poll-id}"
           parameters:@{ @"fields": @"poll_options{text,total_votes}",}
           HTTPMethod:@"GET"];
[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
    // Insert your code here
}];
FB.api(
  '/{your-video-poll-id}',
  'GET',
  {"fields":"poll_options{text,total_votes}"},
  function(response) {
      // Insert your code here
  }
);
try {
  // Returns a `FacebookFacebookResponse` object
  $response = $fb->get(
    '/{your-video-poll-id}',
    '{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

{
  "poll_options":
    {
      "data": [
        {
          "text": "Brown Bear",
          "total_votes": 12,
          "id": 145049637
        },
        {
          "text": "Black Bear",
          "total_votes": 87,
          "id": 67890
        }
        {
          "text": "That's a stupid question",
          "total_votes": 45,
          "id": 145049639
        }
        {
          "text": "Basically, there are two schools of thought",
          "total_votes": 12,
          "id": 145049640
        }
      ]
    },
  "id": 12345
}