首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >DHL卷曲返回空

DHL卷曲返回空
EN

Stack Overflow用户
提问于 2021-10-11 12:49:10
回答 1查看 46关注 0票数 0

我正在做一个DHL ECommerce应用编程接口集成。

文档中提供了以下请求,但当我在PHP中使用CURL库在代码中尝试此请求时,它只是返回以下错误

我尝试使用curl_error($ch)获取错误代码。

有什么建议吗?

谢谢。

给我弄到这个错误。HTTP/1.1 100继续连接:保持连接内容-长度:0

HTTP/1.1405方法不允许连接: close WWW-Authenticate: Basic realm=“集成服务器”,encoding="UTF-8“

请求:

代码语言:javascript
复制
{
    "labelRequest": {
        "hdr": {
            "messageType": "LABEL",
            "messageDateTime": "2021-10-11T19:39:46 GMT+08:00",
            "accessToken": "{removed}",
            "messageVersion": "1.4",
            "messageLanguage": "en"
        },
        "bd": {
            "inlineLabelReturn": "U",
            "customerAccountId": null,
            "pickupAccountId": "34324324",
            "soldToAccountId": "324324324",
            "handoverMethod": null,
            "pickupDateTime": null,
            "pickupAddress": {
                "name": "Jerry",
                "address1": "DHL Express (M) Sdn. Bhd.",
                "address2": "Menara TM .",
                "city": "Laksi",
                "state": "Laksi",
                "district": "Laksi",
                "country": "TH",
                "postCode": "10010",
                "phone": "123456789",
                "email": "jerry@dhl.com"
            },
            "shipperAddress": {
                "name": "Jerry",
                "address1": "DHL Express (M) Sdn. Bhd.",
                "address2": "Menara TM .",
                "city": "Laksi",
                "state": "Laksi",
                "district": "Laksi",
                "country": "TH",
                "postCode": "10010",
                "phone": "123456789",
                "email": "jerry@dhl.com"
            },
            "shipmentItems": [{
                    "consigneeAddress": {
                        "name": "Jerry",
                        "address1": "DHL Express (M) Sdn. Bhd.",
                        "address2": "Menara TM .",
                        "city": "Laksi",
                        "state": "PICKUPstate",
                        "district": "Laksi",
                        "country": "TH",
                        "postCode": "10010",
                        "phone": "123456789",
                        "email": "jerry@dhl.com",
                        "idNumber": " 1023",
                        "idType": "1"
                    },
                    "returnAddress": {
                        "companyName": "DHL",
                        "name": "Jerry",
                        "address1": "DHL Express (M) Sdn. Bhd.",
                        "address2": "Menara TM .",
                        "city": "Laksi",
                        "state": "Laksi",
                        "district": "Laksi",
                        "country": "TH",
                        "postCode": "10010",
                        "phone": "123456789",
                        "email": "jerry@dhl.com"
                    },
                    "shipmentID": "3242341234324",
                    "deliveryConfirmationNo": "238643",
                    "packageDesc": "PKG_desc",
                    "totalWeight": 250,
                    "totalWeightUOM": "G",
                    "dimensionUOM": "cm",
                    "height": 120.0,
                    "length": 5.0,
                    "width": 0.0,
                    "customerReference1": null,
                    "customerReference2": null,
                    "productCode": "PDO",
                    "incoterm": null,
                    "contentIndicator": null,
                    "codValue": null,
                    "insuranceValue": null,
                    "freightCharge": null,
                    "totalValue": null,
                    "currency": "THB",
                    "remarks": "remarks to test",
                    "valueAddedServices": {
                        "valueAddedService": [{
                                "vasCode": "PPOD"
                            }
                        ]
                    },
                    "isMult": "true",
                    "deliveryOption": "P",
                    "shipmentPieces": [{
                            "pieceID": 11,
                            "announcedWeight": {
                                "weight": null,
                                "unit": null
                            },
                            "codAmount": 5,
                            "insuranceAmount": null,
                            "billingReference1": "123",
                            "billingReference2": "123",
                            "pieceDescription": "Air Conditioner"
                        }, {
                            "pieceID": 12,
                            "announcedWeight": {
                                "weight": null,
                                "unit": null
                            },
                            "codAmount": 0.01,
                            "insuranceAmount": null,
                            "billingReference1": "123",
                            "billingReference2": "123",
                            "pieceDescription": "Device"
                        }
                    ]
                }
            ],
            "label": {
                "pageSize": "400x600",
                "format": "PNG",
                "layout": "1x1"
            }
        }
    }
}


function httpPost($url, $strRequest,$userId, $password)
{
    $ch = curl_init();
    $url = "https://sandbox.dhlecommerce.asia/rest/v2/label";

    $headers = array(
        'Accept: application/json',
        'Content-Type: application/json',

    );
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $strRequest);
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($ch, CURLOPT_HEADER, 1);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);

    $result = curl_exec($ch);
    $this->errorCode = curl_errno($ch);
    $this->errorMessage = curl_error($ch);
    return $result;
}
EN

回答 1

Stack Overflow用户

发布于 2021-10-11 17:48:09

这个问题是因为"label“中的字母"l”应该是大写的"L“。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/69526479

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档