【发布时间】: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;
提前致谢。
【问题讨论】: