你的位置:首页 > ASP.net教程

[ASP.net教程]快递鸟物流查询接口API调用代码示例


快递鸟物流查询接口是免费使用的,没有限制,稳定性也还不错,所以接口对接以快递鸟为例,用户ID和KEY需要自己申请http://www.kdniao.com/reg。

using System;using System.Collections.Generic;using System.IO;using System.Linq;using System.Net;using System.Text;using System.Web;/** * * 快递鸟物流轨迹即时查询接口 * * @技术QQ群: 456320272 * @see: http://www.kdniao.com/YundanChaxunAPI.aspx * @copyright: 深圳市快金数据技术服务有限公司 * * DEMO中的电商ID与私钥仅限测试使用,正式环境请单独注册账号 * 单日超过500单查询量,建议接入我方物流轨迹订阅推送接口 */namespace Test{  public class KdApiSearchDemoYS  {    //电商ID    private string EBusinessID = "ID需到官网申请:http://www.kdniao.com/ServiceApply.aspx";    //电商加密私钥,快递鸟提供,注意保管,不要泄漏    private string AppKey = "Key需到官网申请:http://www.kdniao.com/ServiceApply.aspx";    //请求url    private string ReqURL = "http://api.kdniao.cc/Ebusiness/EbusinessOrderHandle.aspx";    /// <summary>    /// Json方式 查询订单物流轨迹    /// </summary>    /// <returns></returns>    public string getOrderTracesByJson(string shipperCode, string expNo)    {      string requestData = "{'OrderCode':'','ShipperCode':'"+shipperCode+"','LogisticCode':'"+expNo+"'}";      Dictionary<string, string> param = new Dictionary<string, string>();      param.Add("RequestData", HttpUtility.UrlEncode(requestData, Encoding.UTF8));      param.Add("EBusinessID", EBusinessID);      param.Add("RequestType", "1002");      string dataSign = encrypt(requestData, AppKey, "UTF-8");      param.Add("DataSign", HttpUtility.UrlEncode(dataSign, Encoding.UTF8));      param.Add("DataType", "2");      string result = sendPost(ReqURL, param);      //根据公司业务处理返回的信息......      return result;    }    /// <summary>    /// 

  


 
 aspx界面示例 
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="KdApiSearchYS.aspx.cs" Inherits="Test.KdApiSearchYS" %><!DOCTYPE html><html 

  aspx.cs代码

using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;namespace Test{  public partial class KdApiSearchYS : System.Web.UI.Page  {    protected void Page_Load(object sender, EventArgs e)    {    }    protected void Button_Click(object sender, EventArgs e)    {      KdApiSearchDemoYS search = new KdApiSearchDemoYS();      string result = search.getOrderTracesByJson(this.txtShipperCode.Text.Trim(), this.txtLogisticCode.Text.Trim());      Response.Write(result);    }  }}