php - 如何使用 PHP 修复 API 不通过 GET 命令返回结果
问题描述
使用 who 是我的代表 API (whoismyrepresentative.com) 并且 get 命令不会呈现来自索引页面上要求邮政编码的输入字段的结果。语法不正确,我需要回显命令吗?
我创建的索引页面:
<section class="form-one">
<form action="search-results.php" method="post">
<label for="zipcode"> Input Zipcode</label>
<input id="zipcode" type="number" name="zip" size="5">
<input type="submit" name="">
</form>
</section>
我调用 GET 命令的 Search-Results.php 页面:
<?php
file_get_contents('https://whoismyrepresentative.com/getall_mems.php?zip=&output=json'.$_GET['zip'].'php?zip=&output=json …');
/*echo $_GET["https://whoismyrepresentative.com/getall_mems.php?zip=&output=json …"];*/
?>
该命令应输出 json。
解决方案
这将起作用:
file_get_contents('https://whoismyrepresentative.com/getall_mems.php?zip=' . $_GET['zip'] . '&output=json');
推荐阅读
- c - 在 C 中将 short 转换为 int 时值发生变化
- python - DRF url 路由与 genericview RetrieveUpdateAPIView 不匹配
- c++ - 使用指针重新设置实体?
- python - 错误:节点:找不到命令构建步骤“执行外壳”将构建标记为失败
- c++ - 有没有办法将控制台滚动到空白部分?
- python - 使用 QThreadPool 时如何杀死工作线程?
- python - 我正在尝试安装 python-unitex 但是在执行安装过程时收到错误消息:'ld: library not found for -lunitex'
- toggle - Google Colab - 切换隐藏/取消隐藏单元格
- mysql - 如何使用 Ebean ORM 在 MySQL 中随机提取记录?
- contiki - ContikiOS的RPL协议中如何计算节点发送或转发的数据包数?