当前位置: 首页 > article >正文

商品条形码查询接口如何用C#进行调用?

一、什么是商品条码查询接口?

1974年6月26日,美国俄亥俄州的一家超市首次使用商品条码完成结算,标志着商品条码正式进入商业应用领域。这项技术通过自动识别和数据采集,极大提升了零售行业的作业效率,减少了人工录入错误,提高了库存管理水平。
如今,商品条码已成为商品在全球流通中的“唯一身份标识”,而商品条码查询接口正是基于这一基础技术,为用户提供快速获取商品信息的能力。用户只需输入13位或14位商品条码,即可获取包括商品名称、品牌、规格、价格、保质期、成分信息等关键数据,广泛服务于消费者、零售商、电商平台、物流企业等多个群体。

二、商品条形码查询接口如何用C#进行调用?

下面我们以阿里云的接口为例,具体代码示例如下:

接口地址:https://market.aliyun.com/apimarket/detail/cmapi00065867
//using System.IO;
//using System.Text;
//using System.Net;
//using System.Net.Security;
//using System.Security.Cryptography.X509Certificates;private const String host = "https://tsbarcode.market.alicloudapi.com";private const String path = "/barcode/index";private const String method = "GET";private const String appcode = "你自己的AppCode";static void Main(string[] args){String querys = "barcode=6921830106820";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;}

返回代码如下:

{"code": 1,"msg": "操作成功","data": {"barcode": "6921830106820","brand": "老厨","goods_name": "老厨香辣牛肉干","company": "温州老厨食品有限公司","keyword": "牛肉干","goods_type": "食品、饮料和烟草>>预制食品和罐头>>小吃>>肉干和处理过的肉","category_code": "10005767","category_name": "预制/加工牛肉","image": "http://tanshu-img.oss-cn-hangzhou.aliyuncs.com/barcode/202416/171328157024fb6f.jpg?Expires=1748410862&OSSAccessKeyId=LTAI5tCFqfpS4Mei4vfBxpdn&Signature=Yn70h%2FoTA9gpUu%2F1rEJ0xt4SRXU%3D","spec": "52g","width": "6.2厘米","height": "9.5厘米","depth": "2厘米","gross_weight": "","net_weight": "","price": "","origin_country": "中国","first_ship_date": "","packaging_type": "","shelf_life": "","min_sales_unit": "50(克)","certification_standard": "GB 2726","certificate_license": "SC11233011000581","remark": "checkResult:1;备注:经查,该商品条码已在中国物品编码中心注册;logout_flag:0;login_date:Sep  3 1997 12:00:00:000AM;valid_date:Sep  3 2023 12:00:00:000AM;宽:6.2;单位:CM;高:9.5;深:2;关键字:老厨牌 牛肉干;上市时间:2014-01-01;英文名称:xianglaniurougan;产地:杭州;gpc2020:10005767;"}
}

http://www.lryc.cn/news/2387683.html

相关文章:

  • 编译pg_duckdb步骤
  • 多模态大语言模型arxiv论文略读(九十一)
  • 攻防世界 - MISCall
  • 数据结构测试模拟题(2)
  • 在PyTorch中,对于一个张量,如何快速为多个元素赋值相同的值
  • 苍穹外卖--Redis
  • C++ 条件变量虚假唤醒问题的解决
  • 深度学习————注意力机制模块
  • openssl 使用生成key pem
  • python:基础爬虫、搭建简易网站
  • 好坏质检分类实战(异常数据检测、降维、KNN模型分类、混淆矩阵进行模型评估)
  • 链表:数据结构的灵动舞者
  • YOLOv4:目标检测的新标杆
  • PyTorch 2.1新特性:TorchDynamo如何实现30%训练加速(原理+自定义编译器开发)
  • LabVIEW通用测控平台设计
  • 【机器学习基础】机器学习入门核心算法:K-近邻算法(K-Nearest Neighbors, KNN)
  • FastMoss 国际电商Tiktok数据分析 JS 逆向 | MD5加密
  • Redis分布式缓存核心架构全解析:持久化、高可用与分片实战
  • 【Linux】基础开发工具(下)
  • Python爬虫实战:研究Portia框架相关技术
  • chrome打不开axure设计的软件产品原型问题解决办法
  • 达梦数据库-学习-23-获取执行计划的N种方法
  • 【数据结构】树形结构--二叉树
  • Baklib构建企业CMS高效协作与安全管控体系
  • 深入理解 JDK、JRE 和 JVM 的区别
  • LSTM 与 TimesNet的时序分析对比解析
  • 图论学习笔记 4 - 仙人掌图
  • 语音识别算法的性能要求一般是多少
  • 百度ocr的简单封装
  • 华为高斯数据库(GaussDB)深度解析:国产分布式数据库的旗舰之作