Reputation: 322
I am working on a project of youtube apps. But I cannot post comment on the any videos. I am using curl and php. I have put all the function correctly but is show error of kind If I am using
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_json);
where $data_json
is
{
"snippet": {
"topLevelComment": {
"snippet": {
"videoId": "<?php echo $videoid; ?>",
"textOriginal": "<?php echo $comment; >"
}
}
}
}
{ "error": { "errors": [ { "domain": "global", "reason": "parseError",
"message": "This API does not support parsing form-encoded input." } ],
"code": 400, "message": "This API does not support parsing form-encoded
input." } }
Please help me out.
Upvotes: 1
Views: 869
Reputation: 39385
You need to mention your content-type
header so that youtube
knows what you are sending. By default you are right now using form-encoded
input.
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
Upvotes: 1