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: アプリケーション/json; charset=UTF-8 Date: Sat, 07 Jan 2012 19:25:32 GMT Expires: Sat, 07 Jan 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 Server: GSE Transfer-Encoding: chunked { "error": { "errors": [ { "domain": "global", "reason": "parseError", "message": "Parse Error" } ], "コード": 400、"メッセージ": "解析エラー" } }