weixin_39735288 2020-11-20 18:03
浏览 0

Natural Language API for PHP cannot work?

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

  • 写回答

2条回答 默认 最新

  • weixin_39735288 2020-11-20 18:03
    关注

    Hey ,

    What is the error you receive with the above code?

    评论

报告相同问题?