PHP进程发布了json

时间:2012-10-01 15:58:30

标签: php json

我有一个VB.net桌面应用程序通过以下方式将webrequest发送到PHP Web服务器:

Dim result_post = SendRequest(New Uri(strURL), data, "application/json", "POST")

使用Newtonsoft json编码过程对数据进行编码

我在PHP端检索已发布的json时遇到问题。

$data = file_get_contents('php://input');
//$data = '[{"products_model":"2481-5-50","products_name":"2481-5-50 Desk, Maple with an extended d","products_description":"Desk, Maple with an extended description\rAnd this is line 2","products_quantity":112,"products_date_available":"2009-07-08T00:00:00","products_url":"","fc_products_id":0,"updated":"2012-04-15T00:00:00","products_price":1109.95,"ImageFile":"","products_tax_class_id":1,"products_weight":0.00}]';

$json = json_decode($data, true);
Foreach ($json as $i => $row) {
   //sql insert code goes here
}

如果我将json文本放在php文件中,则sql插入代码可以正常工作。当我使用file_get_contents版本时,我没有错误,也没有插入数据。

我错过了什么?

1 个答案:

答案 0 :(得分:1)

您可以查看$HTTP_RAW_POST_DATA是否包含您要查找的信息。如果您在ini设置中将always_populate_raw_post_data设置为true,则输入流可能已被读入此变量。

相关问题