I do not found solution, I do my code in base to other code that I found in the web http://zakilive.com/tag/google-cloud-messaging-php-tutorial/ , because in Google not exist sample for php, I have the next Code:
<?php
define( "API_ACCESS_KEY", "my api key" );
$msg = array
(
'document' => array(
'type'=>'PLAIN_TEXT',
'content'=>"Michelangelo Caravaggio, Italian painter, is known for
'The Calling of Saint Matthew'."
),
'encodingType'=>'UTF8',
);
$headers = array
(
'Authorization: Bearer ' . API_ACCESS_KEY,
'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;
The complete response is: { "error": { "code": 400, "message": "The AnnotateTextRequest.features is empty.", "status": "INVALID_ARGUMENT", "details": [ { "@type": "type.googleapis.com/google.rpc.BadRequest", "fieldViolations": [ { "field": "AnnotateTextRequest.features", "description": "No features specified." } ] } ] } }
I could not do the code in other language still.
Help me please
The API is: https://cloud.google.com/natural-language/docs/