duanbicheng3345 2016-05-23 08:54
浏览 20

如何从cURL呼叫接收和处理数据

I have to send a json response from a cURL call. The user send me a "test" variable to file.php.

On my php file, I use this code

$arr = array($arr = array('test' => 'ok'));
echo json_encode($arr);

And this for the cURL call

curl --request POST http://www.domain.com/WS/file.php -d '{ "test" : "12341234123412342" }'

Here is the answer

[{"test":null}]

What's the good way to get de POST variable and treat it in my php file?

Thanks

EDIT

Just in case, the problem comes from the cURL call. Here's the correct syntax:

curl -H "Content-Type: application/json" -X POST -d "{\"test\":\"12341234123412342\"}" http://www.domain.com/WS/file.php
  • 写回答

3条回答 默认 最新

  • douwu5428 2016-05-23 09:34
    关注

    Ur question is kinda confusing :)

    so ur User sends u a variable in file.php and u have to curl with that variable ?

    why not just

    curl --request POST http://www.domain.com/WS/file.php -d '{ "test" : "$_POST['USER_INPUT_VALUE']" }'
    

    or am i missing something ?

    评论

报告相同问题?

悬赏问题

  • ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分
  • ¥15 Macbookpro 连接热点正常上网,连接不了Wi-Fi。
  • ¥15 delphi webbrowser组件网页下拉菜单自动选择问题
  • ¥15 linux驱动,linux应用,多线程
  • ¥20 我要一个分身加定位两个功能的安卓app
  • ¥15 基于FOC驱动器,如何实现卡丁车下坡无阻力的遛坡的效果
  • ¥15 IAR程序莫名变量多重定义
  • ¥15 (标签-UDP|关键词-client)
  • ¥15 关于库卡officelite无法与虚拟机通讯的问题
  • ¥15 目标检测项目无法读取视频