-1

I am new to PHP. I am trying to call a web service (written in Java) that is in the following format URL:

http://geoserver.com/track?uid='user'&sdate='sdatetime'&edate='edate' 'etime'

It is returning JSON data in following format:

[{"lat":"1","lng":"2","time":"2013-06-23 14:00:42"},
{"lat":"3","lng":"4","time":"2013-06-23 14:10:10"},
{"lat":"5","lng":"6","time":"2013-06-23 14:21:00"}]

How can I call this URL through PHP?

Fabrício Matté
  • 69,329
  • 26
  • 129
  • 166
Devil's Dream
  • 655
  • 3
  • 15
  • 38

1 Answers1

1

There is couple of ways to call this using php. one method is using curl, another method would be using file_get_contents

if using file_get_contents

$json = file_get_contents("http://geoserver.com/track?uid='user'&sdate='sdatetime'&edate='edateetime'");

$output = json_decode($json);

//you can access 

 $output[0]->lat; //your object properties this way.
DevZer0
  • 13,433
  • 7
  • 27
  • 51