由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
BuildingWeb版 - Help --- Parsing posted JSON data (转载)
相关主题
other urls Re: 怎么设置可以看到CODE?如何让一个域名完全镜像另外一个域名?
如何限制用户的访问 ?quesiton about PHP! waiting online
ASP.NET 如何接收JSON格式的HTTP POST江湖救急!!! 面试XML的一个问题!!!
FORM中用POST时数据是怎么打包传送的?排序问题
???post variables in php (or javascript)怎么抓一个页面submit后的结果页面?
[转载] How to hide the URL in status bar in a webpage?如何把这些转变成中文
谁能帮我一个大忙,先万分感谢!PHP: Mysql 得parse 问题
unlink the current menu item如何从程序里自动访问网站?
相关话题的讨论汇总
话题: json话题: post话题: jsonobj话题: server话题: php
进入BuildingWeb版参与讨论
1 (共1页)
z*****e
发帖数: 74
1
【 以下文字转载自 Linux 讨论区 】
发信人: zteddie (独滑求伴(Blue+)), 信区: Linux
标 题: Help --- Parsing posted JSON data
发信站: BBS 未名空间站 (Mon Apr 2 17:02:19 2012, 美东)
Hi, I am trying to do following, not sure if it is possible:
1: On server one, posting data using:
curl -i -X POST -d 'json={
"disk": {
"root": "56%",
"tmp" : "4%",
"opt" : "7%",
"var" : "9%"
}
}'
2: On http server 2, a PHP script is used to capture the JSON data:
var_dump( $_POST['json'] );
$jsonObj = json_decode( $_POST['json'], true );
var_dump( $jsonObj );
?>
But dump $jsonObj is NULL.
I am new to JSON ... any idea what I am missing?
Thanks
s****y
发帖数: 983
2
you can't post json with nvp unless encrypted, so simply post a raw json
string
curl -i -X POST -d '{
"disk": {
"root": "56%",
"tmp" : "4%",
"opt" : "7%",
"var" : "9%"
}
}'
in php snippet, get json string with php://input
$json = json_decode(file_get_contents('php://input'), true );
1 (共1页)
进入BuildingWeb版参与讨论
相关主题
如何从程序里自动访问网站????post variables in php (or javascript)
Looking for UI expert (转载)[转载] How to hide the URL in status bar in a webpage?
Sever端程序,获取另外一个web site的用户输入的功能叫什么谁能帮我一个大忙,先万分感谢!
一个傻问题,具体这个怎么写?unlink the current menu item
other urls Re: 怎么设置可以看到CODE?如何让一个域名完全镜像另外一个域名?
如何限制用户的访问 ?quesiton about PHP! waiting online
ASP.NET 如何接收JSON格式的HTTP POST江湖救急!!! 面试XML的一个问题!!!
FORM中用POST时数据是怎么打包传送的?排序问题
相关话题的讨论汇总
话题: json话题: post话题: jsonobj话题: server话题: php