Menjadwalkan Siaran

Penjadwalan video siaran langsung tidak berlaku lagi untuk v12.0 dan akan tidak berlaku lagi untuk semua versi mulai 14 Desember 2021. Panggilan ke endpoint POST /ID/live-video dengan parameter planned_start_time akan menampilkan pesan kesalahan.

Anda dapat menggunakan Live Video API untuk membuat video siaran langsung yang akan disiarkan secara langsung pada waktu yang ditentukan sebelumnya, sampai tujuh hari sejak tanggal pembuatannya.

Menjadwalkan Siaran

Untuk membuat video siaran langsung dengan tanggal mulai di masa mendatang pada Pengguna, Halaman, Grup, atau Acara, kirimkan permintaan ke:

POST /{node-id}/live_videos?status=SCHEDULED_UNPUBLISHED&planned_start_time={start-time}

Gunakan parameter planned_start_time dan cap waktu UNIX untuk menetapkan waktu mulai yang diinginkan.

Ini akan membuat objek LiveVideo pada node target dan mengembalikan secure_stream_url dan id dari video siaran langsung. Gunakan URL aliran aman dengan enkoder Anda untuk menyalurkan data video siaran langsung ke objek LiveVideo pada, atau sebelum, waktu mulai yang dijadwalkan. Siaran akan muncul pada linimasa/beranda node pada waktu mulai yang dijadwalkan sepanjang siaran tersebut menerima data aliran.

Siaran terjadwal bisa menerima data aliran kapan saja sebelum tanggal mulainya, untuk tujuan cuplikan.

Contoh Permintaan

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

Contoh Tanggapan

{
  "id": "10214937378883406",  //LiveVideo object ID
  "stream_url": "rtmp://rtmp-api.facebook...",
  "secure_stream_url": "rtmps://rtmp-api.facebook..."  //Stream URL
}

Untuk mendapatkan daftar siaran yang dijadwalkan, lihat Mendapatkan Siaran Terjadwal.

Melihat Cuplikan Siaran

Anda dapat menggunakan Live Video API untuk melihat cuplikan video siaran langsung yang belum diterbitkan; objek LiveVideo dibuat dengan status yang diatur ke SCHEDULED_UNPUBLISHED atau UNPUBLISHED.

Untuk melihat cuplikan video siaran langsung yang belum diterbitkan, kirimkan permintaan ke:

GET /{live_video_id}?fields={fields}

Gunakan parameter {fields} untuk mendapatkan dash_preview_url dari objek LiveVideo.

Contoh Permintaan

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

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

Contoh Tanggapan

{
  'dash_preview_url': 'https://video.xx.fbcdn.net/...',
  'id': '{live-video-id}'
}

Ini mengembalikan dash_preview_url dan id dari video siaran langsung. Salin dan tempelkan URL ke Pemutar Dash untuk melihat cuplikan siaran.

Meski melihat cuplikan siaran Anda dengan pemutar video uji pihak ketiga adalah cara yang bagus untuk memeriksa isi siaran Anda, kami rekomendasikan Anda untuk menyiarkannya pada sebuah halaman uji. Anda harus menjadi admin atau editor halaman untuk dapat menyiarkan halaman. Selain itu, Anda dapat mengatur parameter privasi untuk menyiapkan aliran yang hanya terlihat untuk Anda.

Mendapatkan Siaran Terjadwal

Untuk mendapatkan siaran terjadwal untuk Pengguna, Halaman, Grup, atau Acara, dapatkan token akses yang semestinya dengan izin publish_video dan kirimkan permintaan ke:

GET /{node-id}/live_videos?broadcast_status=["SCHEDULED_UNPUBLISHED"]

Harap diketahui bahwa nilai broadcast_status haruslah array. Buka referensi LiveVideo untuk melihat daftar lengkap nilai tambahan.

Contoh Daftar Siaran untuk sebuah Halaman

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

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

Contoh Tanggapan

{
  "data": [
    {
      "status": "SCHEDULED_UNPUBLISHED",
      "stream_url": "rtmp://rtmp-api-dev.facebook.com:80/rtmp/...",
      "secure_stream_url": "rtmps://rtmp-api-dev.facebook.com:443/rtmp/...",
      "embed_html": "<iframe src=\"https://www.facebook.com/plugins/video.php?...",
      "id": "10214937378883406 "  //LiveVideo object ID
    }
  ]
}

Menjadwalkan Siaran

Anda dapat mengubah waktu mulai siaran terjadwal dengan mengirimkan permintaan ke:

POST /{live-video-id}?planned_start_time={new-start-time}

Nilai {new-start-time} harus berupa cap waktu UNIX yang menunjukkan waktu mulai yang baru. Setelah berhasil, API akan menanggapi dengan ID objek LiveVideo.

Contoh Video Siaran Langsung untuk Halaman

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

Contoh Tanggapan

{
  "id": "10214937378883406"
}

Memulai Siaran Segera

Anda dapat memulai siaran segera dengan mengirimkan permintaan ke:

POST /{live-video-id}?status=LIVE_NOW

Siaran akan ditayangkan langsung jika URL aliran yang terkait dengan objek LiveVideo, yang mewakili siaran tersebut, menerima data aliran. Setelah berhasil, API akan menanggapi dengan ID objek LiveVideo.

Contoh Permintaan

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

Contoh Tanggapan JSON

{
  "id": "10214937378883406"
}