【问题标题】:How to send json data from advance rest client and then receive in php web API?如何从高级休息客户端发送 json 数据,然后在 php Web API 中接收?
【发布时间】:2017-04-30 16:40:32
【问题描述】:

我正在为 ios 开发人员在 API 中为 I am writing the API that receives the array of items 编写 API,首先我无法发送 JSON 数据。

但我收到无效的回复,您可以查看下面的图片。 那么如何发送 JSON 数组数据并获得响应呢?我通过发送一个工作正常但不知道如何发送项目数组的键值对开发了许多 API。这是我尝试获取值的代码。

require_once('db/db_config.php');
$enable_log = 0;
if ($enable_log) {

$data = ' GET DATA ' . print_r($_GET, 1);
$data = ' GET DATA ' . print_r($_FILES, 1);
$data .= ' POST DATA ' . print_r($_POST, 1);
$time = @date('[d/M/Y:H:i:s]');
error_log($time . $data . PHP_EOL, 3, "login.log");
}
//call to helper function
$app_type = request_check();
$token = isset($_REQUEST['token']) ? $_REQUEST['token'] : '';
$employee_id = isset($_REQUEST['employee_id']) ? $_REQUEST['employee_id'] : '';
$order_item_array = isset($_REQUEST['ordered_items']) ?  $_REQUEST['ordered_items'] : '';

$decode = (array) json_decode($_REQUEST['ordered_items'], true);
echo "<pre>";print_r($decode);exit;

提前致谢。

【问题讨论】:

    标签: php ios json api


    【解决方案1】:

    将您的数据转换为 Json 而不是 base 64 并使用 post 调用 url,您可以发送大量转换为 Json 的数据

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-11-14
      • 1970-01-01
      • 1970-01-01
      • 2017-08-14
      • 2020-03-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多