douliao2493 2012-10-01 15:58
浏览 46

PHP进程发布了json

I have a VB.net desktop app sending webrequest to a PHP web server via:

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

The data is encoded using the Newtonsoft json encoding process

I am having a problem on the PHP side retrieving the posted 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 descriptionAnd 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
}

If I put the json text in the php file, the sql insert code works. When I use the file_get_contents version I get no errors but also no inserted data.

What am I missing?

  • 写回答

1条回答 默认 最新

  • douyong1886 2012-10-01 16:08
    关注

    You can check to see if $HTTP_RAW_POST_DATA contains the information you are looking for. If you have always_populate_raw_post_data set to true in your ini settings, then the input stream may have already been read into this variable.

    评论

报告相同问题?

悬赏问题

  • ¥15 winform的chart曲线生成时有凸起
  • ¥15 msix packaging tool打包问题
  • ¥15 finalshell节点的搭建代码和那个端口代码教程
  • ¥15 用hfss做微带贴片阵列天线的时候分析设置有问题
  • ¥15 Centos / PETSc / PETGEM
  • ¥15 centos7.9 IPv6端口telnet和端口监控问题
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 海浪数据 南海地区海况数据,波浪数据
  • ¥20 软件测试决策法疑问求解答