私は解決策が見つかりませんでした.Googleに存在しないため、http://zakilive.com/tag/google-cloud-messaging-php-tutorial/Google Cloud Natural Language APIでこのエラーが発生しました:PHPでAnnotateTextRequest.featuresが空です
<?php
define("API_ACCESS_KEY", "my api key");
$msg = array
(
\t 'document' \t => array(
\t
\t \t 'type'=>'PLAIN_TEXT',
\t \t 'content'=>"Michelangelo Caravaggio, Italian painter, is known for
'The Calling of Saint Matthew'."
\t
\t),
\t 'encodingType'=>'UTF8',
);
$headers = array
(
\t 'Authorization: Bearer ' . API_ACCESS_KEY,
\t 'Content-Type: application/json'
);
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL, 'https://language.googleapis.com/v1beta1/documents:annotateText');
curl_setopt($ch,CURLOPT_POST, true);
curl_setopt($ch,CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch,CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch,CURLOPT_POSTFIELDS, json_encode($msg));
$result = curl_exec($ch);
curl_close($ch);
echo $result;
完全な応答がある: { "エラー":{ "コード":400、 "メッセージ":「AnnotateTextRequest.features PHPのサンプル、私は次のコードを持っています空 "、"ステータス ":" INVALID_ARGUMENT "、"詳細 ":[{" @type ":" type.googleapis.com/google.rpc.Ba dRequest "、" fieldViolations ":[{" field ":" AnnotateTextRequest.features "、" description ":"機能が指定されていません " }]}]}}
他の言語でもコードを実行できませんでした。
APIである私を助けてください:https://cloud.google.com/natural-language/docs/
あなたはそれを働かせてください。私はいつもこのエラーを受け取っています」リクエストはクライアントプロジェクトでは特定できません。リクエストに有効なAPIキーを渡してください。 –
FYI [このプロジェクト](https://github.com/darrynten/google-natural-language-php)は、このAPIを使用する際に役立つ場合があります –