我有一个 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 版本时,我没有收到任何错误,但也没有插入数据。
我错过了什么?