带 PHP CURL 的 Google Map Place API

问题描述 投票:0回答:0

我在 PHP 中通过 CURL 调用使用了 Google Map Place API,我从 CURL 调用中获取了数据,但我需要限制我的 API 密钥,当我使用网站 URL 限制我的 API 密钥时,它不起作用。我需要在 PHP CURL 中做什么。请帮助我

我的代码在这里

                        curl_setopt_array($curl, array(
                            CURLOPT_URL => 'https://maps.googleapis.com/maps/api/place/details/json?place_id=PlaceID&key=APIKey&language=en',
                            CURLOPT_RETURNTRANSFER => true,
                            CURLOPT_ENCODING => '',
                            CURLOPT_MAXREDIRS => 10,
                            CURLOPT_TIMEOUT => 0,
                            CURLOPT_FOLLOWLOCATION => true,
                            CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
                            CURLOPT_CUSTOMREQUEST => 'GET',
                            CURLOPT_HTTPHEADER => array(
                                'Accept: application/json'
                            ),
                        ));

                        $response = curl_exec($curl);
                        $data = json_decode($response);

API key的限制应该没问题

dictionary
© www.soinside.com 2019 - 2024. All rights reserved.