以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  如何在FOXTABLE中调用阿里云中的快递查询  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=96900)

--  作者:fpx406
--  发布时间:2017/3/2 8:49:00
--  如何在FOXTABLE中调用阿里云中的快递查询
各位老师,
我想在ft中实现快递单号查询,购买了阿里云中的单号查询服务。
https://market.aliyun.com/products/57126001/cmapi010996.html#sku=yuncode499600008

我想请教各位老师,如何将以下代码转换成foxtable中可以使用的代码
谢谢!
import urllib, urllib2, sys


host = \'http,https://ali-deliver.showapi.com\'
path = \'/showapi_expInfo\'
method = \'GET\'
appcode = \'你自己的AppCode\'
querys = \'com=shunfeng&nu=883420070249072469\'
bodys = {}
url = host + path + \'?\' + querys

request = urllib2.Request(url)
request.add_header(\'Authorization\', \'APPCODE \' + appcode)
response = urllib2.urlopen(request)
content = response.read()
if (content):
    print(content)

--  作者:fpx406
--  发布时间:2017/3/2 8:53:00
--  
以下是C#的请求代码
//using System.Net.Security;
//using System.Security.Cryptography.X509Certificates;

        private const String host = "http,https://ali-deliver.showapi.com";
        private const String path = "/showapi_expInfo";
        private const String method = "GET";
        private const String appcode = "你自己的AppCode";

        static void Main(string[] args)
        {
            String querys = "com=shunfeng&nu=883420070249072469";
            String bodys = "";
            String url = host + path;
            HttpWebRequest httpRequest = null;
            HttpWebResponse httpResponse = null;

            if (0 < querys.Length)
            {
                url = url + "?" + querys;
            }

            if (host.Contains("https://"))
            {
                ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
                httpRequest = (HttpWebRequest)WebRequest.CreateDefault(new Uri(url));
            }
            else
            {
                httpRequest = (HttpWebRequest)WebRequest.Create(url);
            }
            httpRequest.Method = method;
            httpRequest.Headers.Add("Authorization", "APPCODE "+appcode);
            if (0 < bodys.Length)
            {
                byte[] data = Encoding.UTF8.GetBytes(bodys);
                using (Stream stream = httpRequest.GetRequestStream())
                {
                    stream.Write(data, 0, data.Length);
                }
            }
            try
            {
                httpResponse = (HttpWebResponse)httpRequest.GetResponse();
            }
            catch (WebException ex)
            {
                httpResponse = (HttpWebResponse)ex.Response;
            }

            Console.WriteLine(httpResponse.StatusCode);
            Console.WriteLine(httpResponse.Method);
            Console.WriteLine(httpResponse.Headers);
            Stream st = httpResponse.GetResponseStream();
            StreamReader reader = new StreamReader(st, Encoding.GetEncoding("utf-8"));
            Console.WriteLine(reader.ReadToEnd());
            Console.WriteLine("\\n");

        }

        public static bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
        {
            return true;
        }
[此贴子已经被作者于2017/3/2 9:02:37编辑过]

--  作者:fpx406
--  发布时间:2017/3/2 8:54:00
--  
以下是返回的样式
{
	"showapi_res_code": 0,//showapi平台返回码,0为成功,其他为失败
	"showapi_res_error": "",//showapi平台返回的错误信息
	"showapi_res_body": {
		"mailNo": "968018776110",//快递单号
		"update": 1466926312666,//数据最后查询的时间
		"updateStr": "2016-06-26 15:31:52",//数据最后更新的时间
		"ret_code": 0,//接口调用是否成功,0为成功,其他为失败
		"flag": true,//物流信息是否获取成功
		"status": 4,-1 待查询 0 查询异常 1 暂无记录 2 在途中 3 派送中 4 已签收 5 用户拒签 6 疑难件 7 无效单
 8 超时单 9 签收失败 10 退回
		"tel": "400-889-5543",//快递公司电话
		"expSpellName": "shentong",//快递字母简称
		"data": [//具体快递路径信息
			{
				"time": "2016-06-26 12:26",
				"context": "已签收,签收人是:【本人】"
			},
			{
				"time": "2016-06-25 15:31",
				"context": "【陕西陇县公司】的派件员【西城业务员】正在派件"
			},
			{
				"time": "2016-06-25 14:11",
				"context": "快件已到达【陕西陇县公司】"
			},
			{
				"time": "2016-06-25 09:08",
				"context": "由【陕西宝鸡公司】发往【陕西陇县公司】"
			},
			{
				"time": "2016-06-24 14:08",
				"context": "由【陕西西安中转部】发往【陕西宝鸡公司】"
			},
			{
				"time": "2016-06-22 13:23",
				"context": "由【山东临沂公司】发往【陕西西安中转部】"
			},
			{
				"time": "2016-06-21 23:02",
				"context": "【江苏常熟公司】正在进行【装袋】扫描"
			},
			{
				"time": "2016-06-21 23:02",
				"context": "由【江苏常熟公司】发往【江苏江阴航空部】"
			},
			{
				"time": "2016-06-21 18:30",
				"context": "【江苏常熟公司】的收件员【严继东】已收件"
			},
			{
				"time": "2016-06-21 16:41",
				"context": "【江苏常熟公司】的收件员【凌明】已收件"
			}
		],
		"expTextName": "申通快递"//快递公司名
	}
}

--  作者:有点蓝
--  发布时间:2017/3/2 9:21:00
--  

直接把c#代码转换为vb即可以用了,转换网站:http://codeconverter.sharpdevelop.net/SnippetConverter.aspx

 


--  作者:有点色
--  发布时间:2017/3/2 9:58:00
--  

查快递的方式很多吧?比如菜鸟快递

 

http://www.foxtable.com/bbs/dispbbs.asp?BoardID=2&ID=93954&skin=0

 

 


--  作者:狐狸爸爸
--  发布时间:2017/3/2 9:59:00
--  
等我下次更新,给HttpClient加一个Headers属性,目前你没有简单的办法。
--  作者:狐狸爸爸
--  发布时间:2017/3/2 10:31:00
--  
下次更新,你只需3行代码就行了:

查询快递单号
Dim hc As New HttpClient("http://ali-deliver.showapi.com/showapi_expInfo?com=shunfeng&nu=929601675231")
hc.Headers.Add("Authorization","APPCODE " & "7858a126750949e4a36371580f420413")
Return hc.getData()

--  作者:fpx406
--  发布时间:2017/3/2 11:04:00
--  
谢谢狐爸
--  作者:狐狸爸爸
--  发布时间:2017/3/2 12:21:00
--  
去重新下载安装,然后参考:



--  作者:fpx406
--  发布时间:2017/3/2 12:49:00
--  
预计啥时候可以发布呀