我是PHP的新手,也是使用RESTful API的全部内容.我现在想做的就是成功向OpenStreetMap API发出一个纯HTTP GET请求.
我正在使用tcdent的简单PHP REST客户端,我基本上了解它的功能.我在OSM中获取当前Changeset的示例代码是:
<?php
include("restclient.php");
$api = new RestClient(array(
'base_url' => "http://api.openstreetmaps.org/",
'format' => "xml")
);
$result = $api->get("api/0.6/changesets");
if($result->info->http_code < 400) {
echo "success:<br/><br/>";
} else {
echo "failed:<br/><br/>";
}
echo $result->response;
?>
Run Code Online (Sandbox Code Playgroud)
当我在浏览器中输入URL"http://api.openstreetmaps.org/api/0.6/changesets"时,它会传递XML文件.但是,通过此PHP代码,它将返回OSM 404 File not Found页面.
我想这是一个相当愚蠢的PHP新手问题,但我看不出我错过了什么,因为我对所有这些客户端 - 服务器端进程等知之甚少.
谢谢你的帮助!