Я пытаюсь обновить мою модель в php.Я могу тренироваться и предсказывать, но я не могу обновить.Может быть, это из-за использования PUT, но я не могу найти проблему.Вот код:
$authCode = $_GET['token'];
$man =$_GET['owner'];
$type = $_GET['type'];
$title= $_GET['title'];
$id = "*****";
$api_key = "**********************";
$url = "https://www.googleapis.com/prediction/v1.4/trainedmodels/".$id."?pp=1&key=".$api_key;
$header = array('Content-Type:application/json','Authorization: OAuth '.$authCode);
$str = "label=dislike&csvInput[]=video&csvInput[]=war&csvInput[]=john";
parse_str($str, $output);
$putData = tmpfile();
fwrite($putData, $output);
fseek($putData, 0);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_PUT, true);
curl_setopt($ch, CURLOPT_INFILE, $putData);
curl_setopt($ch, CURLOPT_INFILESIZE, strlen($output));
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$ss = curl_exec($ch);
curl_close($ch);
echo(print_r($ss));
Ответ:
HTTP / 1.1 400 Bad Request Content-Type: application / json;charset = UTF-8 Дата: суббота, 07 января 2012 19:25:32 GMT Истекает: суббота, 07 января 2012 19:25:32 GMT Cache-Control: private, max-age = 0 X-Content-Type-Options:nosniff X-Frame-Options: SAMEORIGIN X-XSS-Protection: 1;mode = block Сервер: GSE Transfer-Encoding: chunked {"error": {"errors": [{"domain": "global", "reason": "parseError", "message": "Ошибка разбора"}],"code": 400, "message": "Ошибка разбора"}}