In the recent work process, there was a need to manage GeoServer in external programs. By checking the documents, we found that the REST interface of GeoServer can meet the requirements. The REST interface uses HTTP call. You can simply call and configure GeoServer without logging on to the Web management interface.
Introduction to the REST configuration API and example on the GeoServer official website address: http://docs.geoserver.org/stable/en/user/rest/index.html
The following program uses the REST interface to request a list of layers in GeoServer.
<? = "Http: // localhost: 8180/geoserver/rest/layers/" = curl_init (, CURLOPT_RETURNTRANSFER,); curl_setopt (, CURLOPT_VERBOSE,); curl_setopt (, CURLOPT_GET, = "admin: geoserver"; curl_setopt (, CURLOPT_USERPWD, CURLOPT_HTTPHEADER, ("Accept: application/json ")); = 200 = curl_exec (= curl_getinfo (['HTTP _ Code']! = "Request failed! "= Json_decode (, = ['layers'] ['layer' (=> [] = ['name' json_encode (?>
Blog statement:
All the articles in this blog, except the words "reprinted" in the title, are original articles or summarized after reading the materials. Please note this statement when referencing non-reprinted articles. -- Blog garden-pallee