dongwuge6201 2019-05-25 22:54
浏览 44

如何在cURL PHP中发出post请求后获得Acknowledgement和实际响应

I'm sending request to an API end point which is supposed to return a response based on the information i sent. I am getting the Acknowledgement of success, but the actual information i'm expecting is not returned.

my cURL request is on the code below, i tried changing the timeout. also checked the tcpdump on the online server : tcpdump has the expected response but still cannot display on the php page.

on localhost i used wireshark to track the request and response but on wireshark i cannot see the expected results and also not displayed on the page when i print the response

NB: response is XML that should look like this

        $API_endpoint = "http://xxx.xxx.xx.xx:80/api/bill/sigqrequest";

        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $API_endpoint);
        curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_TIMEOUT, 20);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
        curl_setopt($ch, CURLOPT_HTTPHEADER, array(
            'Content-Type:application/xml',
            'g-Com:default.sp.in',
            'g-Code:SP172',
            'Content-Length:' . strlen($payload)

        ));
        curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13');


        $response = curl_exec($ch);

echo $response;

i Expect

    <BillSubResp>
        <BillTrxInf>
            <BillId>MC_2019_27</BillId>
            <PayCntrNum>0</PayCntrNum>
            <TrxSts>GF</TrxSts>
            <TrxStsCode>7223;7201</TrxStsCode>
        </BillTrxInf>
    </BillSubResp>
    <Signature>CT3r/yvVSB9dnbD59LNare2nhwWQq2vCtamcMw==</Signature>

and I get

<BillSubReqAck>
    <TrxStsCode>7101</TrxStsCode>
</BillSubReqAck>
<Signature>QxabtcSqgr08g</Signature>

which is just an acknowledgement.

What am I doing Wrong?

Request-Ack

I want to get the Response and instead i am getting that acknowledgement from remote System. and on tcpdump on my online server i sometime see the response and still is not displayed on my page when i echo the Response

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 GDI处理通道视频时总是带有白色锯齿
    • ¥20 用雷电模拟器安装百达屋apk一直闪退
    • ¥15 算能科技20240506咨询(拒绝大模型回答)
    • ¥15 自适应 AR 模型 参数估计Matlab程序
    • ¥100 角动量包络面如何用MATLAB绘制
    • ¥15 merge函数占用内存过大
    • ¥15 Revit2020下载问题
    • ¥15 使用EMD去噪处理RML2016数据集时候的原理
    • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大
    • ¥15 单片机无法进入HAL_TIM_PWM_PulseFinishedCallback回调函数