Monday, 15 June 2015

YouTube Data API - Resumable Uploads - Start a resumable session - Errors -



YouTube Data API - Resumable Uploads - Start a resumable session - Errors -

running parseerror attempting follow "start resumable session" youtube info api - resumable uploads documentation.

complete list of efforts ,response , code

i read on google apis - "global domain errors" page "parseerror api server cannot parse request body." i have watched "youtube developers live: debugging & dealing errors" still know clue there i have read "stack on flow" similar questions, never answered,or answers still united nations clear the test youtube business relationship want upload has youtube channel videos i tried client php upload api, found out later not resumable upload. i thought resumable upoad improve option, dont frustrate users, wasting there time,if there connection drops out.... i runing php hostgator account i noticed how when did not error, homecoming regular snippet , status info , not "step 2 - save resumable session uri" info i using long lived access tokens pulled database...in requests, youtube user has channel videos before stored access tokens i check access tokens tokeninfo? i noticed changing "uploadtype" "uploadtype" produce "message": "media type 'application/json; charset=utf-8'

is not supported. valid media types: [video/*, application/octet-stream]",following error changing content type "application/octet-stream" homecoming "kind = youtube#video object json snippet,status" not step 2 - save resumable session uri, changed things "uploadtype" , "application/json; charset=utf-8" facing same parse error

i notice in docs "parameter values in request url must url-encoded." when urlencode() "parameter values" homecoming errors or parseerror when removed urlencode function even changing "host: www.googleapis.com" "host: https://www.googleapis.com" produce "the requested url /upload/youtube/v3/videos not found on server. that’s know." parse error appears persistent far i have changed urlencode() rawurlencode() still parse error i add together charset=utf-8;multipart/form-data;application/octet-stream content type header, still parse error i notice content type on string text/plain; charset=us-ascii not sure if google server expects pure application/json

any help great…

array ( [response] => array ( [0] => { "error": { "errors": [ { "domain": "global", "reason": "parseerror", "message": "parse error" } ], "code": 400, "message": "parse error" } } ) [headers] => [ "post \/upload\/youtube\/v3\/videos?uploadtype=resumable&part=snippet,status http\/1.1", "host: www.googleapis.com", "authorization: bearer ya29.vaay5n3sjq3ucg7z4tohehdxyj9z7mxfentd5pkf_djqfllqwcktrhtrejkugy_nrjd3kmetkeba_w", "content-length: 303", "content-type: application\/json; charset=utf-8", "x-upload-content-length: 20121", "x-upload-content-type: video\/*" ] [curl_resource] => resource id #18 [video_aray] => { "snippet": { "title": "test video", "description": "testing api", "tags": [ "any", "thing" ], "categoryid": 25 }, "status": { "privacystatus": "public", "embeddable": true, "license": "youtube" } } [json_requestbody] => { "snippet": { "title": "test video", "description": "testing api", "tags": [ "any", "thing" ], "categoryid": 25 }, "status": { "privacystatus": "public", "embeddable": true, "license": "youtube" } } [request_url] => https://www.googleapis.com/upload/youtube/v3/videos?uploadtype=resumable&part=snippet,status [content_type_of_request] => text/plain; charset=us-ascii [0] => text/plain; charset=us-ascii [1] => text/plain; charset=us-ascii )

source

public function startresumablesession() { $videoresource = array( 'snippet'=>array('title'=>"test video",'description'=>"testing api", 'tags'=>array("any","thing"),'categoryid'=>25), 'status'=>array('privacystatus'=>"public",'embeddable'=>true,'license'=>"youtube")); $requestbody = json_encode($videoresource,json_pretty_print); $headers = array ( "post /upload/youtube/v3/videos?uploadtype=resumable&part=snippet,status http/1.1", "host: www.googleapis.com", "authorization: bearer ya29.vaay5n3sjq3ucg7z4tohehdxyj9z7mxfentd5pkf_djqfllqwcktrhtrejkugy_nrjd3kmetkeba_w", "content-length: ".strlen($requestbody), "content-type: application/json; charset=utf-8", "x-upload-content-length: 20121", "x-upload-content-type: video/*" ); /* parameter values in request url must url-encoded. */ $url = "https://www.googleapis.com/upload/youtube/v3/videos?uploadtype=resumable&part=snippet,status"; $ch = curl_init(); curl_setopt($ch, curlopt_url,$url); curl_setopt($ch, curlopt_httpheader,$headers); curl_setopt($ch, curlopt_postfields,urlencode($requestbody)); curl_setopt($ch, curlopt_returntransfer,true); $result = curl_exec($ch); $json = json_decode($result); /* check request body contenttype */ $finfo = new finfo(fileinfo_mime); $t1= $finfo->buffer($requestbody); $t2 = $finfo->buffer("test"); $t3 = $finfo->buffer(utf8_encode("test")); /* debug info */ homecoming array( 'response'=>(array)$result, 'headers'=>json_encode($headers,json_pretty_print), 'curl_resource'=>$ch, 'video_aray'=>json_encode($videoresource,json_pretty_print), 'json_requestbody'=>$requestbody, 'request_url'=>$url, 'content_type_of_request'=>$t1,$t2,$t3 ); }

easy reply - wrong.

you not supposed add together "post", "host:" , "content-length:" $headers because generated curl (curlopt_url , curlopt_postfields).

youtube api works correctly. not fault.

upload youtube resume-upload

No comments:

Post a Comment