我使用谷歌的地方API添加一个地方,当收到“REQUEST_DENIED”。 我已经搜查一主题,我敢肯定,关键是正确的,因为它可以用于谷歌搜索的地方。
也许它的东西与我的编码? 这是我的PHP代码:
$jsonpost = '{
"location": {
"lat": ' .$coordinate[0] .',
"lng": ' .$coordinate[1] . '
},
"accuracy": 50,
"name": ' . $locator_name .'",
"types": ["other"],
"language": "en"
}';
$url = "https://maps.googleapis.com/maps/api/place/add/json?sensor=true&key=AIzaSyCj9yH5x6_5_Om8ebAO2pBlaqJZB-TIViY";
$results = json_decode(ProcessCurl ($url, $jsonpost), TRUE);
echo "<script>alert('Google Places submission returned " . $results["status"] ."');</script><br />";
function ProcessCurl($URL, $fieldString){ //Initiate Curl request and send back the result
$ch = curl_init($URL);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $fieldString);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_VERBOSE, TRUE);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($fieldString))
);
$result = curl_exec($ch);
if (curl_errno($ch)) {
print curl_error($ch);
} else {
curl_close($ch);
}
return $result;
}