Code Monkey home page Code Monkey logo

dhl's Introduction

dhl

DHL API测试工具

验证信息

在脚本运行目录创建文件credentials,根据环境对credentials内容进行配置。

测试环境(sanbox)

username:password                       # for authorization 
2222222222_customer:uBQbZ62!ZiBiVVbhc   # for authentication

第一行中username和password分别为DHL Entwickler Portal登录用户名和密码。第二行为DHL官方提供的测试帐号,无需进行修改。

生产环境(production)

AppId:token   # for authorization
user:pwd      # for authentication

第一行分别为Application的id和token,可以在DHL开发者后台Release&Operation中相应Application获取。 第二行分别为DHL商业后台生成的用户的用户名和密码。

HTTP数据格式

运行目录中的data.json为生成DHL Retoure面单所需数据,格式为json,作为HTTP数据提交。数据示例:

{
  "receiverId": "deu",
  "customerReference": "123456789",
  "shipmentReference": "Sendungsreferenz",
  "senderAddress": {
    "name1": "Zhang San",
    "name2": "Li Si",
    "name3": "Wang Wu",
    "streetName": "Vegesacker Heerstr.",
    "houseNumber": "111",
    "postCode": "28757",
    "city": "Bremen",
    "country": {
      "countryISOCode": "DEU",
      "country": "Germany"
    }
  },
  "email": "[email protected]",
  "telephoneNumber": "+49 351 987654321",
  "weightInGrams": 5000,
  "returnDocumentType": "SHIPMENT_LABEL"
}

reveiverId

收件人Id,测试环境中通常是国家代码,如DE等。生产环境中的receiverId为商业用户预先设置好的收件人Id,每个收件人Id对应的收货地址将被自动填写在API返回的包裹单中。ReceiverId可以在商业用户后台中获取,一个商业用户可以拥有多个receiverId。

customerReference

预留字段

shipmentReference

预留字段

senderAddress

发件人信息

weightInGrams

包裹重量,单位为克。

运行脚本

完成上述准备工作后运行脚本:

python returns.py

如果运行成功会在运行目录生成文件名为Retoure.pdf的文件,即所需的DHL Retoure面单,可参见示例文件Retoure.pdf。

API返回数据说明:

{
  "shipmentNumber":"999990184381",
  "labelData":"JVBERi0xLjQKJeLjz9......",  # 很长一串
  "qrLabelData":null,
  "routingCode":"40327653113+99000933090010"
}

shipmentNumber

包裹单号

labelData

包裹单pdf文件原始数据的base64编码。对此字段进行base64解码即可得到包裹单pdf文件的原始数据,可直接保存成pdf文件。

dhl's People

Contributors

junessi avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Forkers

maox1122

dhl's Issues

Two questions for you

How to get
con.setRequestProperty("Authorization", "Basic XXXXXX");
con.setRequestProperty("DPDHL-User-Authentication-Token", "YYYYYY");
this two parms

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.