I've downloaded the library via composer installation onto my XAMPP server for simple testing in local environment. Shouldn't it be straight forward and echo entity?
Rather new in php and google cloud NL API please tell me how to get it to work am i missing some steps?
<?php use Google\Cloud\NaturalLanguage\NaturalLanguageClient;
$language = new NaturalLanguageClient([
'projectId' => 'My unique project ID copied from my google console' // Enabled my Google NL API
]);
// Analyze a sentence.
$annotation = $language->annotateText('Greetings from Michigan!');
$entities = $annotation->entitiesByType('LOCATION');
foreach ($entities as $entity) {
echo $entity['name'] . "\n";
}
?>
该提问来源于开源项目:googleapis/google-cloud-php