Google PHP 클라이언트 라이브러리를 사용하여 YouTube API를 사용하여 워터 마크를 설정할 수 없습니다.

StackOverflow https://stackoverflow.com//questions/21004169

문제

GitHub에서 새로운 Google API PHP 클라이언트 라이브러리를 사용하고 있습니다.다음은 코드입니다.

$client = new Google_Client();
$client->setClientId( 'CLIENTID' );
$client->setClientSecret( 'CLIENTSECRET' );
$client->refreshToken( 'REFRESHTOKEN' );
$youtube = new Google_Service_YouTube( $client );
$channelId = 'UC...';
$imagePath = "./image.jpeg";
$postBody = new Google_Service_YouTube_InvideoBranding();
$postBody->setImageBytes( filesize( $imagePath ) );
$postBody->setTargetChannelId( $channelId );
$imageData = file_get_contents( $imagePath );
$resource = array(
    'data' => $imageData,
    'mimeType' => 'image/jpeg,image/png,application/octet-stream',
    'uploadType' => 'media'
);
$youtube->watermarks->set( $channelId, $postBody, $resource );
.

그러나 다음 예외가 있습니다.

PHP Warning:  file_get_contents(/upload/youtube/v3/watermarks/set?channelId=UC...&uploadType=multipart): failed to open stream: No such file or directory in ....../src/Google/IO/Stream.php on line 109
PHP Fatal error:  Uncaught exception 'Google_IO_Exception' with message 'HTTP Error: Unable to connect' in ....../src/Google/IO/Stream.php:112
Stack trace:
#0 ....../src/Google/Http/REST.php(46): Google_IO_Stream->makeRequest(Object(Google_Http_Request))
#1 ....../src/Google/Client.php(492): Google_Http_REST::execute(Object(Google_Client), Object(Google_Http_Request))
#2 ....../src/Google/Service/Resource.php(194): Google_Client->execute(Object(Google_Http_Request))
#3 ....../src/Google/Service/YouTube.php(2687): Google_Service_Resource->call('set', Array)
#4 .../watermark.php(48): Google_Service_YouTube_Watermarks_Resource->set('UC...', Object(Google_Service_YouTube_InvideoBranding), Array)
#5 {main}
  thrown in ....../src/Google/IO/Stream.php on line 112
.

"set thumbnail"과 유사합니다.내가 어디에서 잘못하고 있니?

도움이 되었습니까?

해결책

google_http_mediafileupload를 사용하여 이미지 파일을 업로드하십시오.

다음은 예제입니다. https : // github.COM / YOUTUBE / API- 샘플 / BLOB / 마스터 / PHP / upload_thumbnail.php # L78

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top