我如何把张贴的JSON值到PHP? [英] How do I turn a POSTed JSON value into PHP?

查看:130
本文介绍了我如何把张贴的JSON值到PHP?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

作为测试,此JSON数据被张贴到我的网站:

As a test, this JSON data is being POSTed to my website:

{
    "order": {
        "id": null,
        "created_at": null,
        "status": "new",
        "total_btc": {
            "cents": 100000000,
            "currency_iso": "BTC"
        },
        "total_native": {
            "cents": 2263,
            "currency_iso": "USD"
        },
        "custom": "123456789",
        "button": {
            "type": "buy_now",
            "name": "Test Item",
            "description": null,
            "id": null
        },
        "transaction": {
            "hash": "4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b",
            "confirmations": 0
        }
    }
}

由于它是被发送的服务器到服务器我不能明显地看到的数据。我曾尝试发送$ _POST数组到一个文本文件,但它出现空白。我想,我需要做的是:

Since it is being sent server-to-server I cannot visibly see the data. I have tried sending the $_POST array to a text file, but it comes up blank. What I think I need to do is:

$data = json_decode($jsonData);

但我怎么设置变量$ jsonData?

But how do I set the variable $jsonData?

推荐答案

您可以尝试使用的包装获取读取原始POST查询。

You can try to use wrappers for reading raw POST query.

$data = file_get_contents("php://input");

这篇关于我如何把张贴的JSON值到PHP?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆