I have the following code, modified from Google\'s documentation:
$GOOGLE_APPLICATION_CREDENTIALS = \"./[path].json\";
$_ENV[\"GOOGLE_APPLICATION
I agree with the above answer, but only want to describe if user getting error in php using nlp google:
useApplicationDefaultCredentials();
# Your Google Cloud Platform project ID
$projectId = 'nlp-project-nname'; //your project name
# Instantiates a client
$language = new LanguageClient([
'projectId' => $projectId
]);
# The text to analyze
$text = 'Sachin Tendulkar';
# Detects the sentiment of the text
$annotation = $language->analyzeSentiment($text);
$sentiment = $annotation->sentiment();
echo "";
print_r($annotation); die;
echo 'Text: ' . $text . '
Sentiment: ' . $sentiment['score'] . ', ' . $sentiment['magnitude'];
?>