1

除了 POST、GET、COOKIE、SESSION 和 RAW 之外,还有其他方式接收表单吗?

我解释说:我正在尝试用 PHP 实现 cXML Punchout,但似乎我没有收到通常发送的信息。我尝试用 PHP、GET、POST 甚至原始数据来捕捉它:

file_get_contents('php://input')

但我没有抓住任何变量。

我找到了一个向我的程序发送虚拟请求的 URL:https ://punchoutcommerce.com/tools/cxml-punchout-tester

如果我向我的程序 ( https://serlimax.com/api )发送请求,它不会在我的日志中注册任何内容,但我看到使用浏览器工具发送了 CXML-Urlencoded。

我用浏览器工具看到的

我如何捕捉我看到的那些信息?

pS:如果您想在浏览器中自己查看,可以发送除现有 URL 以外的任何信息,否则会发送 404 错误。 寄什么

PS2:如果你想知道我怎么知道我没有收到任何东西,这就是我记录收到的信息的方式:

ob_flush();
ob_start();
echo "User: - ". $_SERVER['HTTP_USER_AGENT']. ' - IP:'. $_SERVER['REMOTE_ADDR'].' - METHOD:'.$_SERVER['REQUEST_METHOD'].PHP_EOL;
echo 'POST:---------'.PHP_EOL;
var_dump($_POST);
echo 'GET:---------'.PHP_EOL;
var_dump($_GET);
echo 'RAW:---------'.PHP_EOL;
echo file_get_contents('php://input');
file_put_contents('./punchout_log_'.date("j.n.Y.H.i.s").'.txt', ob_get_flush());

导致空日志: 在此处输入图像描述

4

2 回答 2

2

问题是您“记录”您发布的数据不正确。你用:

file_get_contents('php://input');

但是,这会返回数据。由于您不回显它,因此它不会在您的日志文件中可见。

把它改成这样:

echo file_get_contents('php://input');

更改后,您将看到所需的 XML:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE cXML SYSTEM "http://xml.cxml.org/schemas/cXML/1.2.041/cXML.dtd">
<cXML payloadID="1576588580.7783@punchoutcommerce.com" timestamp="2019-12-17T13:16:20+00:00">
  <Header>
    <From>
      <Credential domain="NetworkId">
        <Identity>test</Identity>
      </Credential>
    </From>
    <To>
      <Credential domain="DUNS">
        <Identity>tww</Identity>
      </Credential>
    </To>
    <Sender>
      <Credential domain="NetworkId">
        <Identity>ewe</Identity>
        <SharedSecret>wew</SharedSecret>
      </Credential>
      <UserAgent>PunchOutCommerce PunchOut Tester</UserAgent>
    </Sender>
  </Header>
  <Request deploymentMode="production">
    <PunchOutSetupRequest operation="create">
      <BuyerCookie>76930ae895ac62a2a7e0c9d9350fa5f2</BuyerCookie>
      <Extrinsic name="User">jdoe12345</Extrinsic>
      <Extrinsic name="UniqueUsername">jdoe12345</Extrinsic>
      <Extrinsic name="UserId">12345</Extrinsic>
      <Extrinsic name="UserEmail">jdoe@example.com</Extrinsic>
      <Extrinsic name="UserFullName">John Doe</Extrinsic>
      <Extrinsic name="UserPrintableName">John Doe</Extrinsic>
      <Extrinsic name="FirstName">John</Extrinsic>
      <Extrinsic name="LastName">Doe</Extrinsic>
      <Extrinsic name="PhoneNumber">555-555-5555</Extrinsic>
      <BrowserFormPost>
        <URL>https://punchoutcommerce.com/tools/cxml-punchout-return</URL>
      </BrowserFormPost>
      <SupplierSetup>
        <URL>http://52.211.159.83/test.php?test=1</URL>
      </SupplierSetup>
      <ShipTo>
        <Address addressID="TEST">
          <Name xml:lang="en">TEST</Name>
          <PostalAddress>
            <Street>123 Street Address</Street>
            <City>Rockville</City>
            <State>MD</State>
            <PostalCode>20850</PostalCode>
            <Country isoCountryCode="US">US</Country>
          </PostalAddress>
        </Address>
      </ShipTo>
    </PunchOutSetupRequest>
  </Request>
</cXML>
于 2019-12-17T13:21:02.070 回答
0

好吧,我不知道,但这是由于使用https://url/api/而不是https://url/api/index.php

“index.php”的缺失导致重定向,避免捕获 php://input

于 2019-12-18T02:35:10.467 回答