YouTube API PHP V3:使用RecordingDetails上传(Google API Client V2)

时间:2016-08-06 23:25:33

标签: php youtube

一旦包含“RecordingDetails”,每个Youtube上传调用都会失败。

以下简单调用(提取):

$rc=new \Google_Service_YouTube_VideoRecordingDetails();
$rc->setRecordingDate('2016-08-02T21:17:00.000Z');
$video->setRecordingDetails($rc);

失败。 我也尝试了一个位置:

$rc=new \Google_Service_YouTube_VideoRecordingDetails();
$ld=new \Google_Service_YouTube_GeoPoint();
$ld->setLatitude(36.527294814546);
$ld->setLongitude(128.5400390625);
$rc->setLocation($ld);
$video->setRecordingDetails($rc);

发生相同的错误。 此外,错误消息实际上没有帮助:)

"error": {
  "errors": [
   {
    "domain": "youtube.part",
    "reason": "unexpectedPart",
    "message": "{0}",
    "locationType": "parameter",
    "location": "part"
   }
  ],
  "code": 400,
  "message": "{0}"
 }
}

是否有人已提及使用Api V3和Google Client V2以及RecordingDetail上传视频?

如果有人感兴趣,这就是RecordingDetails对象的样子:

Google_Service_YouTube_VideoRecordingDetails Object
(
    [locationType:protected] => Google_Service_YouTube_GeoPoint
    [locationDataType:protected] => 
    [locationDescription] => 
    [recordingDate] => 2016-08-02T21:17:00.000Z
    [internal_gapi_mappings:protected] => Array
        (
        )

    [modelData:protected] => Array
        (
        )

    [processed:protected] => Array
        (
        )

    [location] => Google_Service_YouTube_GeoPoint Object
        (
            [altitude] => 
            [latitude] => 36.527294814546
            [longitude] => 128.5400390625
            [internal_gapi_mappings:protected] => Array
                (
                )

            [modelData:protected] => Array
                (
                )

            [processed:protected] => Array
                (
                )

        )

)

谢谢, 克里斯托弗

1 个答案:

答案 0 :(得分:1)

更改此

$youtube->videos->insert('status,snippet', $video);

到此

$youtube->videos->insert('status,snippet,recordingDetails', $video);

如果需要,交换插入以进行更新。