Magento getPost 空数组

dha*_*rdy 2 http-post magento

我有以下代码(请原谅错误的编码,就像调试一样):

$postData = Mage::app()->getRequest()->getPost();
if(!$postData)
{
    $postData = $this->getRequest()->getPost(); 
}
if(!$postData)
{
    $postData = $_POST; 
}
Run Code Online (Sandbox Code Playgroud)

正如您所看到的,我只是想获取 HTTP POST 值。

这是场景:

  1. 数据来自 HTTP POST 模拟器
  2. 从 Shopify webhook 没有任何结果(只是“Array()”)
  3. Shopify 发布到 PostCatcher 显示大量数据

Shopify 以 JSON 格式发布。

关于我无法捕获 POST 数组有什么想法吗?

Ela*_*san 5

您无法JSON通过简单地使用$_POST或来获取后值Mage::app()->getRequest()->getPost();。试试这个,

$value = json_decode(file_get_contents('php://input'));
print_r($value);
Run Code Online (Sandbox Code Playgroud)