google地点REQUEST_DENIED [英] google place REQUEST_DENIED

查看:94
本文介绍了google地点REQUEST_DENIED的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些PHP代码可以将地点添加到Google地点,但是我收到REQUEST_DENIED错误,我也不知道为什么:

I have some PHP-code to add a place to google places, but I get a REQUEST_DENIED error back and I don't know why:

        $data = array(
        "location" => array("lat"=>floatval(trim($latlng[1])),"lng"=>floatval($latlng[0])),
        "accuracy" => 50,
        "name" => urlencode($edtName),
        "types" => array(urlencode($cmbType[0]))
        );
        echo "sending to google:<br>";
        echo json_encode($data);
        $ch = curl_init();
        $post_values = json_encode( $data );
        curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
        curl_setopt($ch, CURLOPT_URL, 'https://maps.googleapis.com/maps/api/place/add/json?sensor=false&key=xxx');
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
        curl_setopt($ch, CURLOPT_VERBOSE, 1);

        curl_setopt($ch, CURLOPT_POSTFIELDS, $post_values);
        $data = curl_exec($ch);
        if(!curl_errno($ch))
        {
          echo 'Received raw data' . $data;
        }

我检查了我的google API密钥,并尝试了两种类型:用于浏览器应用程序的密钥(具有引荐来源)"和用于服务器应用程序的密钥(具有IP锁定)",但是两者的结果相同

I checked my google API key and I tried both types: "Key for browser apps (with referers)" and "Key for server apps (with IP locking)" but both with the same result

是否可以获取有关为什么我的请求被拒绝的更多信息?错误的机芯或错误的钥匙?

Is there a way to get more info about why my request is denied? Wrong loaction or wrong key?

这是发送给Google的数据:

This is the data sent to google:

{"location":{"lat":4.63762250793,"lng":51.148788446},"accuracy":50,"name":"Binnenspeeltuin+Het+Fort%2C+Kessel","types":["amusement_park"]}

推荐答案

感谢您的建议,我终于发现我做错了:

Thanks for your advices, I finally found what I did wrong:

在Google中,我的服务器应用程序密钥(具有IP锁定)的定义"中,我填写了服务器的IP地址.我以为只能在该服务器上使用该密钥是一种Xtra安全性,但这是一个客户端IP检查器.

In Google in the definition of my "Key for server apps (with IP locking)" I filled in the Ip-address of my server. I thought it was an xtra security that this key could only be used from that server, but it's a client IP checker.

所以我清除了IP区域,现在它可以正常工作

So I cleared the IP-area and now it works fine

谢谢

这篇关于google地点REQUEST_DENIED的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆