Google Places API REQUEST_DENIED(使用有效的API密钥)

时间:2012-09-21 16:02:39

标签: google-maps google-places-api

当我尝试使用API​​并模拟不同的位置时,我收到REQUEST_DENIED错误。 API文档中的示例参数有效但当我使用不同的Lat和Long coord时,它会以REQUEST_DENIED的形式反弹。它大约一个星期前工作。请问我该怎么办?

php中的

代码:

...... ////

                  $url = "https://maps.googleapis.com/maps/api/place/search/json?location=".$latitude.",
                  ".$longitude."&radius=100&sensor=false&key=".$key."";

                   // Open the Curl session
                      $session = curl_init($url);

                      // If it's a POST, put the POST data in the body
                      //if ($_POST['path']) {
                          $postvars = '';
                          while ($element = current($_GET)) {
                              $postvars .= urlencode(key($_GET)).'='.urlencode($element).'&';
                              next($_GET);
                          }
                          curl_setopt ($session, CURLOPT_POST, true);
                          curl_setopt ($session, CURLOPT_POSTFIELDS, $postvars);
                      //}

                      // Don't return HTTP headers. Do return the contents of the call
                      curl_setopt($session, CURLOPT_HEADER, false);
                      curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
                      curl_setopt($session, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); 
                      //curl_setopt($session, CURLOPT_USERPWD, $username.':'.urldecode($password));

                      // Make the call
                      $json = curl_exec($session);

0 个答案:

没有答案