โพลล์

คุณสามารถใช้ API นี้ในการสร้างและจัดการโพลล์ในการแพร่ภาพวิดีโอถ่ายทอดสดซึ่งมีสถานะเป็น LIVE ได้ ระบบจะใช้อ็อบเจ็กต์ VideoPoll เพื่อแสดงถึงโพลล์ และโพลล์จะประกอบด้วย VideoPollOptions ซึ่งแสดงถึงคำตอบต่างๆ ที่เป็นไปได้สำหรับคำถามของโพลล์ดังกล่าว

สร้างโพลล์

หากต้องการสร้างโพลล์ในการแพร่ภาพวิดีโอถ่ายทอดสด ให้ส่งคำขอไปยัง

POST /{live-video-id}/polls?question={question}&options={options}

อ็อบเจ็กต์ LiveVideo ที่ถูกกำหนดเป็นเป้าหมายจะต้องมี status เป็น LIVE เพื่อให้สามารถสร้าง VideoPoll ขึ้นมาได้ เมื่อสำเร็จ API จะตอบกลับด้วย ID ของอ็อบเจ็กต์ VideoPoll

พารามิเตอร์สตริงการสืบค้น

  • {question} — คำถามของโพลล์
  • {options} — อาร์เรย์คำตอบที่เป็นไปได้

โปรดดูรายการพารามิเตอร์สตริงการสืบค้นทั้งหมดที่คุณสามารถใส่ไว้ขณะสร้างโพลล์ได้ที่ข้อมูลอ้างอิงเกี่ยวกับจุดเชื่อมโยงโพลล์บนวิดีโอถ่ายทอดสด

ข้อกำหนด

ประเภทคำอธิบาย

โทเค็นการเข้าถึง

โทเค็นการเข้าถึงของผู้ใช้หรือเพจที่สร้าง LiveVideo

ฟีเจอร์

สำหรับ VideoPoll บน LiveVideo ในกลุ่ม:


สิทธิ์การอนุญาต

สำหรับ VideoPoll บน LiveVideo ในผู้ใช้:


สำหรับ VideoPoll บน LiveVideo ในเพจ:


สำหรับ VideoPoll บน LiveVideo ในกลุ่ม:


ตัวอย่างคำขอ

curl -i -X POST \
  "https://graph.facebook.com/v3.3/10214959467675612/polls
    ?question=What%20kind%20of%20bear%20is%20best%3F
    &options=%5B%22Black%20bear%22%2C%20%22Brown%20bear%22%2C%20%22That's%20a%20ridiculous%20question%22%5D
    &access_token={access-token}"
GraphRequest request = GraphRequest.newPostRequest(
  accessToken,
  "/10214959467675612/polls",
  new JSONObject("{\"question\":\"What kind of bear is best?\",\"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:@"/10214959467675612/polls"
           parameters:@{ @"question": @"What kind of bear is best?",@"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(
  '/10214959467675612/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(
    '/10214959467675612/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();

ตัวอย่างการตอบกลับ

{
  "id": "2318567914888258"  // VideoPoll ID
}

ปิดโพลล์

หากต้องการปิดโพลล์ในการแพร่ภาพวิดีโอถ่ายทอดสดหลังจากที่มีผู้เลือกตัวเลือกของโพลล์แล้ว ให้ส่งคำขอไปยัง

POST /{video-poll-id}?action=CLOSE

ข้อกำหนด

ประเภทคำอธิบาย

โทเค็นการเข้าถึง

โทเค็นการเข้าถึงของผู้ใช้ที่สร้าง VideoPoll

ฟีเจอร์

สำหรับ VideoPoll บน LiveVideo ในกลุ่ม:


สิทธิ์การอนุญาต

สำหรับ VideoPoll บน LiveVideo ในผู้ใช้:


สำหรับ VideoPoll บน LiveVideo ในเพจ:


สำหรับ VideoPoll บน LiveVideo ในกลุ่ม:


ตัวอย่างคำขอ

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

ตัวอย่างการตอบกลับ

{
  "success": true
}

เปิดโพลล์อีกครั้ง

หากต้องการเปิดโพลล์อีกครั้งเพื่อให้ผู้ใช้สามารถเปลี่ยนตัวเลือกของโพลล์ได้ ให้ส่งคำขอไปยัง

POST /{video-poll-id}?action=SHOW_VOTING

ข้อกำหนด

ประเภทคำอธิบาย

โทเค็นการเข้าถึง

โทเค็นการเข้าถึงของผู้ใช้ที่สร้าง VideoPoll

ฟีเจอร์

สำหรับ VideoPoll บน LiveVideo ในกลุ่ม:


สิทธิ์การอนุญาต

สำหรับ VideoPoll บน LiveVideo ในผู้ใช้:


สำหรับ VideoPoll บน LiveVideo ในเพจ:


สำหรับ VideoPoll บน LiveVideo ในกลุ่ม:


ตัวอย่างคำขอ

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

ตัวอย่างการตอบกลับ

{
  "success": true
}

แสดงผลลัพธ์ของโพลล์

หากต้องการกำหนดค่าโพลล์ให้แสดงผลลัพธ์หลังจากที่มีผู้โหวตแล้ว ให้ส่งคำขอไปยัง

POST /{video-poll-id}?action=SHOW_RESULTS

ข้อกำหนด

ประเภทคำอธิบาย

โทเค็นการเข้าถึง

โทเค็นการเข้าถึงของผู้ใช้ที่สร้าง VideoPoll

ฟีเจอร์

สำหรับ VideoPoll บน LiveVideo ในกลุ่ม:


สิทธิ์การอนุญาต

สำหรับ VideoPoll บน LiveVideo ในผู้ใช้:


สำหรับ VideoPoll บน LiveVideo ในเพจ:


สำหรับ VideoPoll บน LiveVideo ในกลุ่ม:


ตัวอย่างคำขอ

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

ตัวอย่างการตอบกลับ

{
  "success": true
}

เรียกดูตัวเลือกของโพลล์

หากต้องการเรียกดูคำตอบที่เป็นไปได้ของโพลล์ ให้ส่งคำขอไปยัง

GET /{video-poll-id}?fields=poll_options
GET /{video-poll-id}/poll_options

โปรดดูรายการช่องและจุดเชื่อมโยงที่มีให้ใช้งานที่เอกสารอ้างอิงเกี่ยวกับ VideoPoll

ข้อกำหนด

ประเภทคำอธิบาย

โทเค็นการเข้าถึง

โทเค็นการเข้าถึงของผู้ใช้ที่สร้าง VideoPoll

ฟีเจอร์

สำหรับ VideoPoll บน LiveVideo ในกลุ่ม:


สิทธิ์การอนุญาต

สำหรับ VideoPoll บน LiveVideo ในผู้ใช้:


สำหรับ VideoPoll บน LiveVideo ในเพจ:


สำหรับ VideoPoll บน LiveVideo ในกลุ่ม:


ตัวอย่างคำขอ

เรียกดูคำตอบที่เป็นไปได้ของโพลล์:

curl -i -X GET \
 "https://graph.intern.facebook.com/{video-poll-id}/poll_options
   ?fields=poll_options
   &access_token={access-token}"
GraphRequest request = GraphRequest.newGraphPathRequest(
  accessToken,
  "/{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:@"/{video-poll-id}"
           parameters:@{ @"fields": @"poll_options",}
           HTTPMethod:@"GET"];
[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
    // Insert your code here
}];
FB.api(
  '/{video-poll-id}',
  'GET',
  {"fields":"poll_options"},
  function(response) {
      // Insert your code here
  }
);
try {
  // Returns a `FacebookFacebookResponse` object
  $response = $fb->get(
    '/{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();

ตัวอย่างการตอบกลับ

อ็อบเจ็กต์ที่มีรายการคำตอบที่เป็นไปได้ (รายการ VideoPollOptions)

{
  "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
}

เรียกดูคะแนนโหวตของตัวเลือกในโพลล์

หากต้องการเรียกดูจำนวนโหวตของตัวเลือกในโพลล์ ให้ส่งคำขอไปยัง

GET /{video-poll-option-id}?fields=total_votes

ข้อกำหนด

ประเภทคำอธิบาย

โทเค็นการเข้าถึง

โทเค็นการเข้าถึงของผู้ใช้ที่สร้าง VideoPollOption

ฟีเจอร์

สำหรับ VideoPoll บน LiveVideo ในกลุ่ม:


สิทธิ์การอนุญาต

สำหรับ VideoPoll บน LiveVideo ในผู้ใช้:


สำหรับ VideoPoll บน LiveVideo ในเพจ:


สำหรับ VideoPoll บน LiveVideo ในกลุ่ม:


โทเค็นการเข้าถึง

โทเค็นการเข้าถึงเดียวกันกับที่ใช้เพื่อสร้าง LiveVideo หรือการแพร่ภาพ

ตัวอย่างคำขอ

curl -i -X GET \
 "https://graph.facebook.com/{video-poll-option-id}
   ?fields=total_votes 
   &access_token={access-token}"
GraphRequest request = GraphRequest.newGraphPathRequest(
  accessToken,
  "/{video-poll-option-id}",
  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:@"/{video-poll-option-id}"
           parameters:@{ @"fields": @"total_votes",}
           HTTPMethod:@"GET"];
[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
    // Insert your code here
}];
FB.api(
  '/{video-poll-option-id}',
  'GET',
  {"fields":"total_votes"},
  function(response) {
      // Insert your code here
  }
);
try {
  // Returns a `FacebookFacebookResponse` object
  $response = $fb->get(
    '/{video-poll-option-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();

ตัวอย่างการตอบกลับ

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

เรียกดูคะแนนโหวตของตัวเลือกในโพลล์ทั้งหมด

หากต้องการเรียกดูจำนวนโหวตของคำตอบที่เป็นไปได้แต่ละรายการในโพลล์ ให้ใช้การขยายเงื่อนไขในช่องกับช่อง poll_options เพื่อให้การตอบกลับมีช่อง total_votes รวมอยู่ด้วยใน VideoPollOptions ใดๆ ที่ส่งคืนมา

GET /{video-poll-id}?fields=poll_options{total_votes}

ข้อกำหนด

ประเภทคำอธิบาย

โทเค็นการเข้าถึง

โทเค็นการเข้าถึงของผู้ใช้ที่สร้าง LiveVideo

ฟีเจอร์

สำหรับ VideoPoll บน LiveVideo ในกลุ่ม:


สิทธิ์การอนุญาต

สำหรับ VideoPoll บน LiveVideo ในผู้ใช้:


สำหรับ VideoPoll บน LiveVideo ในเพจ:


สำหรับ VideoPoll บน LiveVideo ในกลุ่ม:


ตัวอย่างคำขอ

เรียกดู VideoPollOptions ทั้งหมด รวมถึงช่อง text และ total_votes ของรายการดังกล่าวใน VideoPoll

curl -i -X GET \
 "https://graph.intern.facebook.com/{video-poll-id}
   ?fields=poll_options{text,total_votes}
   &access_token={access-token}"
GraphRequest request = GraphRequest.newGraphPathRequest(
  accessToken,
  "/{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:@"/{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(
  '/{video-poll-id}',
  'GET',
  {"fields":"poll_options{text,total_votes}"},
  function(response) {
      // Insert your code here
  }
);
try {
  // Returns a `FacebookFacebookResponse` object
  $response = $fb->get(
    '/{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();

ตัวอย่างการตอบกลับ

{
  "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
}