I’m tying to use php to consume a restful web service from the following url.
http://www.onemap.sg/API/services.svc/basicSearch?token=qo/s2TnSUmfLz+32CvLC4RMVkzEFYjxqyti1KhByvEacEdMWBpCuSSQ+IFRT84QjGPBCuz/cBom8PfSm3GjEsGc8PkdEEOEr&searchVal=City Hall&otptFlds=SEARCHVAL,CATEGORY&returnGeom=0&rset=1
I tried to use cURL
<?php
$url='http://www.onemap.sg/API/services.svc/basicSearch?token=qo/s2TnSUmfLz+32CvLC4RMVkzEFYjxqyti1KhByvEacEdMWBpCuSSQ+IFRT84QjGPBCuz/cBom8PfSm3GjEsGc8PkdEEOEr&searchVal=City Hall&otptFlds=SEARCHVAL,CATEGORY&returnGeom=1&rset=1'; //rss link for the twitter timeline
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$resp = curl_exec($curl);
echo($resp);
curl_close($curl);
?>
Somehow it doesn’t show anything when I ran this code.
Am I missing anything? Btw this is the first time I’m trying to do such a thing.
*edit added echo($resp); but still doesnt work
It seems like you are not consuming the API like it is meant.
When i execute the following code
I get
This leads me to believe that you need to change the way you call the API. Like registering for a token.
Please follow the steps provided at http://www.onemap.sg/API/Help/ => OneMap REST APIs => Get TOken
They explain how to request a token