<?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;
}
}
我正在使用上面的代码段添加google place 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中集成该过程。我怎么能这样做。
答案 0 :(得分:0)
添加以下行:
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
以避免证书检查。