从PHP中,如何调用外部JSON Web服务然后解码返回的字符串?
例如(伪代码):
<?php
$var jsonStr = json_decode("http://maps.google.com/maps/api/geocode/json?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA&sensor=false");
?>
答案 0 :(得分:19)
你几乎拥有它!
<?php
$jsonObject = json_decode(file_get_contents("http://maps.google.com/maps/api/geocode/json?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA&sensor=false"));
?>
答案 1 :(得分:0)