在PHP中使用谷歌地点api添加地点


Adding place using google place api in PHP

<?php
class MyClass Extends CI_controller{
public function index(){
    $jsonpost = '{
                  "location": {
                    "lat": -33.8669710,
                    "lng": 151.1958750
                  },
                  "accuracy": 50,
                  "name": "Google Shoes!",
                  "phone_number": "(02) 9374 4000",
                  "address": "48 Pirrama Road, Pyrmont, NSW 2009, Australia",
                  "types": ["shoe_store"],
                  "website": "http://www.google.com.au/",
                  "language": "en-AU"
                }';
    $url = "https://maps.googleapis.com/maps/api/place/add/json?key=AIzaSyCuM8rztQMtRpD2ivmjgJaLZgWloyq12l4";
    $results = $this->ProcessCurl ($url, $jsonpost);
    echo $results."<BR>";
  }
  public function ProcessCurl($URL, $fieldString){ //Initiate Curl request and send back the result  
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
    curl_setopt($ch, CURLOPT_URL, $URL);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
    curl_setopt($ch, CURLOPT_VERBOSE, 1);
    //curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $fieldString);
    $resulta = curl_exec ($ch);
    if (curl_errno($ch)) {
            print curl_error($ch);
    } else {
    curl_close($ch);
    }
    echo $resulta;
    }
  }

我正在使用上面的代码片段来添加一个带有谷歌地点 API 的地方。但是我收到一个错误

SSL certificate problem: unable to get local issuer certificate

由于我使用的是codeigniter框架,我需要在框架中添加一些库。实际上我是第一次尝试这个,我研究了以下文档

https://developers.google.com/places/documentation/search#PlaceSearchRequests

https://developers.google.com/places/documentation/actions#place

并尝试将该过程集成到 PHP 中。我该怎么做。

添加此行:

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);

以避免证书检查。