Chúng tôi đang sử dụng API phát trực tiếp trên YouTube cùng với Google API PHP Client và tôi không thể làm cách nào để sử dụng API đó (nhập trước) cơ bản thay vì tùy chỉnh một.Sử dụng chế độ nhập cơ bản khi sử dụng API phát trực tiếp trên YouTube hoặc tránh các tùy chỉnh trùng lặp
Tùy chỉnh là OK, nhưng vì một số lý do ngay cả khi bạn gọi cho chúng cùng tên, nó liên tục tạo bản sao cho mỗi luồng bạn tạo.
Vì vậy, câu hỏi của tôi là, làm cách nào để chúng tôi sử dụng tính năng nhập cơ bản hoặc có thể chọn tùy chỉnh mà không phải tạo tài khoản mới mỗi lần?
Ví dụ ở đây là ăn cơ bản bạn có thể chọn khi bạn thiết lập một dòng suối bằng tay trong tài khoản YouTube của bạn:
Các liên quan PHP mã:
// Create an object for the liveBroadcast resource's snippet. Specify values
// for the snippet's title, scheduled start time, and scheduled end time.
$broadcastSnippet = new Google_Service_YouTube_LiveBroadcastSnippet();
$broadcastSnippet->setTitle($this->title);
$broadcastSnippet->setDescription($this->desc);
$broadcastSnippet->setScheduledStartTime($this->start_time);
// Create an object for the liveBroadcast resource's status, and set the
// broadcast's status.
$status = new Google_Service_YouTube_LiveBroadcastStatus();
$status->setPrivacyStatus($this->privacy_status);
// Create the API request that inserts the liveBroadcast resource.
$broadcastInsert = new Google_Service_YouTube_LiveBroadcast();
$broadcastInsert->setSnippet($broadcastSnippet);
$broadcastInsert->setStatus($status);
$broadcastInsert->setKind('youtube#liveBroadcast');
// Execute the request and return an object that contains information
// about the new broadcast.
$broadcastsResponse = $this->youtube->liveBroadcasts->insert('snippet,status', $broadcastInsert, array());
// Create an object for the liveStream resource's snippet. Specify a value
// for the snippet's title.
$streamSnippet = new Google_Service_YouTube_LiveStreamSnippet();
$streamSnippet->setTitle($this->stream_title);
// Create an object for content distribution network details for the live
// stream and specify the stream's format and ingestion type.
$cdn = new Google_Service_YouTube_CdnSettings();
# TODO: Update the below `Format` method to use the new 'resolution' and 'frameRate' methods
$cdn->setFormat($this->format);
$cdn->setIngestionType('rtmp');
// Create the API request that inserts the liveStream resource.
$streamInsert = new Google_Service_YouTube_LiveStream();
$streamInsert->setSnippet($streamSnippet);
$streamInsert->setCdn($cdn);
$streamInsert->setKind('youtube#liveStream');
// Execute the request and return an object that contains information
// about the new stream.
$streamsResponse = $this->youtube->liveStreams->insert('snippet,cdn', $streamInsert, array());
// Bind the broadcast to the live stream.
$bindBroadcastResponse = $this->youtube->liveBroadcasts->bind(
$broadcastsResponse['id'], 'id,contentDetails',
array(
'streamId' => $streamsResponse['id'],
));
Câu hỏi được cập nhật để hiển thị ví dụ về * nhập cơ bản *. – Brett
@Brett đã cập nhật câu trả lời của tôi. – JAL
Vâng, tôi biết về 'cdn.format' không được dùng nữa nhưng tiếc là 'Google API PHP Client' chưa thêm hỗ trợ cho cách mới để thực hiện nó nhưng AFAIK; ít nhất là trong nhánh V1. – Brett