I am trying to perform a sentiment analysis with the Google Cloud PHP language client from this tutorial: https://cloud.google.com/natural-language/docs/reference/libraries
In the documentation they say this should work with a plain api key: https://cloud.google.com/docs/authentication/api-keys
I already tried a couple of ways on how to set the api key (plain api key, no oauth), but I am always getting the error: "The request is missing a valid API key."
Here some of my tries:
// Instantiates a client
$language = new LanguageClient([
'projectId' => $projectId,
'key' => $key,
'developerKey' => $key,
'api_key' => $key
]);
$language->setDeveloperKey($key);
// Detects the sentiment of the text
$annotation = $language->analyzeSentiment($texttoanalyze);
$sentiment = $annotation->sentiment();
echo 'Text: ' . $text . 'Sentiment: ' . $sentiment['score'] . ', ' . $sentiment['magnitude'];