I'm trying to use the Google Translate API to translate text input by the user on my php based website. So far I have:
<?php
$google_url = "https://www.googleapis.com/language/translate/v2?key=[API KEY]&q=apple&source=en&target=de";
$handle = curl_init($google_url);
curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($handle);
$responseDecoded = json_decode($response, true);
curl_close($handle);
$google_res = $responseDecoded['data']['translations'][0]['translatedText'];
print_r($response);
?>
This isn't returning anything and I don't know what's wrong. I know that the API is set up correctly as when I enter the url into a browser it returns the following:
{
"data": {
"translations": [
{
"translatedText": "Apfel"
}
]
}
}
It must be something to do with my code which I took from this This Site
Any help would be appreciated as I'm completely stumped. Thanks!
EDIT: thanks to a comment I was able to find out that I'm getting the following cURL error:
Curl error: SSL certificate problem: unable to get local issuer certificate