好的,我认为这应该生成一个 json 响应,但没有打印出来。我错过了什么?我正在尝试将此输入与 url 请求一起发送,然后得到一个 json 响应来打印。
<?php
// Customize this (get ID/token values in your SmartyStreets account)
$authId = urlencode("id");
$authToken = urlencode("id");
// Address input
$input1 = urlencode($_POST["street"]);
$input2 = urlencode($_POST["city"]);
$input3 = urlencode($_POST["state"]);
$input4 = urlencode($_POST["postcode"]);
// Build the URL
$req = "https://api.smartystreets.com/street-address/?street={$input1}&city={$input2}&state={$input3}&postcode={$input4}&auth-id={$authId}&auth-token={$authToken}";
// GET request and turn into associative array
$result = json_decode(file_get_contents($req));
?>
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
</head>
<body>
<div id="panel">
<form action="smarty-geocode.php" name="" method="post">
<input id="addresses" type="hidden" value="">
Street Address
<input id="street" type="textbox" value="" class="address">
<br />
City
<input id="city" type="textbox" value="" class="address">
<br />
State
<input id="state" type="textbox" value="" class="address">
<br />
Zipcode
<input id="postcode" type="textbox" value="" class="address">
<br />
Country
<input id="country" type="textbox" value="" class="address">
<br />
<input type="submit" value="submit" id="#mySubmitButton" />
</form>
</div>
<div id="map-canvas" style="height:40%;top:30px;"></div>
<div>
<?php
echo "<pre>";
print_r($result);
echo "</pre>";
?>
</div>
</body>
</html>