通过地点添加事件会返回404错误:

时间:2012-10-03 12:13:21

标签: php google-places-api

如果我遇到任何问题,请原谅我的术语,我是Google API的新手

我正在尝试通过Places API为单个场所添加事件(列在条形类别下)。我按照这里的说明进行操作:

https://developers.google.com/places/documentation/actions?utm_source=welovemapsdevelopers&utm_campaign=places-events-screencast#event_intro

这是我发布的网址(通过PHP)

https://maps.googleapis.com/maps/api/place/event/add/format?sensor=false&key=AIzaSyAFd-ivmfNRDanJ40pWsgP1(密钥更改)

返回404错误。如果我理解正确,我已将传感器设置为false,因为我不是移动设备,并且已在Google apis中创建了一个API密钥,并启用了PLACES服务。

我是否错过了重要步骤,或者POST提交中的后续错误是否会导致404错误?我可以粘贴我的代码,但我想我会从基础开始。

非常感谢您的帮助,建议和时间。非常感激。

我已将此行添加到我的CurlCall函数中,我认为应该指定一个POST,结果仍然相同。

curl_setopt($ch, CURLOPT_POST, 1);

所以整个函数读取

function CurlCall($url,$topost)
        {
            $ch = curl_init();
            curl_setopt($ch, CURLOPT_HTTPHEADERS, array('Content-Type: application/json'));
            curl_setopt($ch, CURLOPT_POST, 1);
            curl_setopt($ch, CURLOPT_URL, $url);
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
            curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
            curl_setopt($ch, CURLOPT_VERBOSE, TRUE);


            curl_setopt($ch, CURLOPT_POSTFIELDS, $topost);
            $body = curl_exec($ch);
            curl_close($ch);
            echo $body;
            echo '<br>';
            echo 'URL ' . $url;
            echo '<br>';
            return $body;

        }

2 个答案:

答案 0 :(得分:0)

您确定使用的是POST方法而不是GET吗?

答案 1 :(得分:0)

您需要在网址中指定请求的格式,方法是将字词格式更改为jsonxml,具体取决于您的结构和POST您的请求。

XML:

https://maps.googleapis.com/maps/api/place/event/add/xml?sensor=false&key=your_api_key

JSON:

https://maps.googleapis.com/maps/api/place/event/add/json?sensor=false&key=your_api_key