1.简介

"通知服务"(约定为Notification的中文名称),是EbayAPI提供的一个便捷的工具,具有实时性的特点。

其设计思想基于发布-订阅模式。一旦客户端订阅了需要通知的事件,服务器发送通知时,客户端就实时接收从eBay发送的通知。

官网API文档:

http://developer.ebay.com/Devzone/guides/ebayfeatures/Notifications/Notifications.html 此文档应该是最好的第一手资料.

论坛帖子:

http://community.ebay.cn/thread-1200288175-1-1.html 此帖子比较全面.

.NET WebService接收例子:

https://ebaydts.com/eBayKBDetails?KBid=2112 直接可以拿过来用,主要是对SOAP消息接收的配置。

2.Usage

2.1流程描述

1)使用SetNotificationPreference接口去设定订阅的event type、通知地址(email或url)

2)如果选择Email,只需考虑收到邮件之后你将如何处理;

3)如果选择URL,则需要提供一个地址,如ebayapi.company.com的地址来接收,此处注意,端口号尽量使用80(8080和443没有试过,应该可以过),但是用了94,结果死活都收不到。问了ebay的技术,只能用默认端口。

4)当有订阅的event发生时,ebay会主动推送消息去你事先设定好的通知地址上。

2.2 设置接收地址

主要分为提醒邮箱设置默认接收URL指定URL(最多25个)三块。

依次分别是AlertEmail,ApplicationURL,DeliveryURLDetailType

  1. [Test]
  2. public void SetNotification_EnableOrDisable_ApplicaitonDelivery_Test()
  3. {
  4.     var context = ApiContextFactory.GetApiContext(token);
  5.     //var context = SandBoxEnvironment.GetApiContextOfSendBox();
  6.     SetNotificationPreferencesCall call = new SetNotificationPreferencesCall(context);
  7.     var enable = EnableCodeType.Enable;
  8.     var type = new ApplicationDeliveryPreferencesType()
  9.     {
  10.         AlertEmail = "mailto://1050244110@qq.com",
  11.         AlertEnable = enable,
  12.         AlertEnableSpecified = true,
  13.         ApplicationURL = "mailto://1050244110@qq.com",
  14.         ApplicationEnable = enable,
  15.         ApplicationEnableSpecified = true,
  16.         DeliveryURLDetails = new DeliveryURLDetailTypeCollection(
  17.             new DeliveryURLDetailType[] {
  18.             new DeliveryURLDetailType()
  19.             {
  20.                 Status = enable,
  21.                 DeliveryURLName = "seller1_Delivery",
  22.                 DeliveryURL = "http://address1.com",
  23.                 StatusSpecified = true
  24.             },new DeliveryURLDetailType(){
  25.                     Status = enable,
  26.                     DeliveryURLName = "seller2_Delivery",
  27.                     DeliveryURL = "http://address2.com",
  28.                     StatusSpecified = true
  29.             }})
  30.     };
  31.     call.SetNotificationPreferences(type);
  32. }

查看指定结果

  1. [Test]
  2. public void GetNotification_RoleCodeType_Application_Test()
  3. {
  4.     var context = ApiContextFactory.GetApiContext(token);
  5.     //var context = SandBoxEnvironment.GetApiContextOfSendBox();
  6.     GetNotificationPreferencesCall call = new GetNotificationPreferencesCall(context);
  7.     call.GetNotificationPreferences(NotificationRoleCodeType.Application);
  8.     Console.WriteLine(call.ApplicationDeliveryPreferences);
  9.     Console.WriteLine(call.ApplicationDeliveryPreferences.AlertEmail);
  10.     Console.WriteLine(call.ApplicationDeliveryPreferences.ApplicationURL);
  11.     Console.WriteLine(call.ApplicationDeliveryPreferences.AlertEnable.ToString());
  12.     Console.WriteLine(call.ApplicationDeliveryPreferences.ApplicationEnable.ToString());
  13.     Console.WriteLine(call.ApplicationDeliveryPreferences.DeviceType.ToString());
  14.     Console.WriteLine(call.ApplicationDeliveryPreferences.NotificationPayloadType.ToString());
  15.     foreach (DeliveryURLDetailType item in call.ApplicationDeliveryPreferences.DeliveryURLDetails)
  16.     {
  17.         Console.WriteLine(item.DeliveryURL);
  18.         Console.WriteLine(item.DeliveryURLName);
  19.         Console.WriteLine(item.Status.ToString());
  20.     }
  21. }

2.3订阅EventType

  1. [Test]
  2. public void SetNotificationPreferences_EnableOrDisbable_EventTypes()
  3. {
  4.     var context = ApiContextFactory.GetApiContext(token);
  5.     //var context = SandBoxEnvironment.GetApiContextOfSendBox();
  6.     SetNotificationPreferencesCall call = new SetNotificationPreferencesCall(context);
  7.     var enable = EnableCodeType.Enable;
  8.     call.DeliveryURLName = "seller1_ Delivery "; //如果指定了,则使用对应名称的URL,反之,则使用 ApplicationURL
  9.     var coll = new NotificationEnableTypeCollection();
  10.     coll.Add(new NotificationEnableType()
  11.     {
  12.         EventEnable = enable,
  13.         EventEnableSpecified = true,
  14.         EventType = NotificationEventTypeCodeType.AuctionCheckoutComplete,
  15.         EventTypeSpecified = true
  16.     });
  17.     coll.Add(new NotificationEnableType()
  18.     {
  19.         EventEnable = enable,
  20.         EventEnableSpecified = true,
  21.         EventType = NotificationEventTypeCodeType.FixedPriceTransaction,
  22.         EventTypeSpecified = true
  23.     });
  24.     coll.Add(new NotificationEnableType()
  25.     {
  26.         EventEnable = enable,
  27.         EventEnableSpecified = true,
  28.         EventType = NotificationEventTypeCodeType.EndOfAuction,
  29.         EventTypeSpecified = true
  30.     });
  31.     call.SetNotificationPreferences(coll);
  32. }

查看订阅结果

  1. [Test]
  2. public void GetNotification_UserLevel_Test()
  3. {
  4.     var context = ApiContextFactory.GetApiContext(token);
  5.     //var context = SandBoxEnvironment.GetApiContextOfSendBox();
  6.     GetNotificationPreferencesCall call = new GetNotificationPreferencesCall(context);
  7.     call.GetNotificationPreferences(NotificationRoleCodeType.User);
  8.     Console.WriteLine(call.DeliveryURLName);
  9.     Console.WriteLine(call.DetailLevelList.Count);
  10.     foreach (NotificationEnableType item in call.UserDeliveryPreferenceList)
  11.     {
  12.         Console.WriteLine(item.EventEnable.ToString());
  13.         Console.WriteLine(item.EventType.ToString());
  14.     }
  15. }

2.4 邮件接收结果截图

内容就是XML文档。

3.注意事项

3.1 端口

如果使用http或https的方式,端口号尽量使用默认端口号(80,443)

3.2 token

订阅某个卖家的EventType时,需要指定此卖家的token;

3.3 ApplicationDeliveryPreferencesType

当ApplicationDeliveryPreferencesType设置为Disable时,所有启用的订阅事件将不发送,除非将其又设置为Enable。

转载于:https://www.cnblogs.com/pengzhen/p/4583248.html

eBay Notification介绍相关推荐

  1. 13 消息提示 notification 介绍

    Notification: Notification通知可以显示到系统的上方的状态栏(status bar)中. 通知内容的显示分为两个部分: 1.notification area(通知状态栏) 2 ...

  2. 消息栏通知(Notification)介绍

    用过安卓的应该对通知栏消息都很熟悉了,下面是演示通知栏消息的一个Demo,首先来看一下界面,后面是代码,解释就都放在代码里了. java代码 package jason.notification;im ...

  3. android通知栏使用情况,Android通知栏(Notification)介绍及使用

    在使用手机时,咱们经常会碰到各类通知,例如微信,头条,UC等,每天不厌其烦的给你各类推送,固然了咱们今天不讲推送,咱们讲讲通知栏的构建和使用,以及自定义通知栏的布局和使用方法java 构建一个通知栏通 ...

  4. Notification介绍

    是在你的应用常规界面之外展示的消息,当app让系统发送一个消息的时候,消息 首先以图表的形式显示在通知栏,要查看消息的详情需要进入通知抽屉(notificationdrawer中查看) 通知栏和通知抽 ...

  5. Notification桌面提醒:HTML5新功能

    1.Notification介绍 window.Notification,是一个通过浏览器调用桌面弹窗的API,具体效果如下 如今支持Notification基础功能的浏览器有Chrome,Firef ...

  6. 马宁的Windows Phone 7.1初体验(二)——Push Notification

    Push Notification并不是Windows Phone 7.1的新功能,但是之前的文章里对这部分都缺少详细的分析,所以姑且就把Push Notification放到这部分里吧. 很多iOS ...

  7. Prism4学习笔记(七):State-Based Navigation QuickStart

    本节学习了Navigation的一些基本知识,觉得这节比较难.这里讲学习和理解点的东西记录下来.觉得本节应该弄清楚的问题的关键词 (1)CallMethodAction用于事件和行为的绑定. (2)I ...

  8. 刘备学Android目录

    准备篇-刘备,从编草鞋到编代码...1 第1回     哦,何为Android?...1 1.1. Android基本知识...1 1.1.1. Android的历史...2 1.1.2. Andro ...

  9. 不去奥斯汀同样收获满满,OpenStack技术峰会议题大揭秘

    奥斯汀峰会正在美国火热上演,您是否还在为没能现场感受OpenStack的火热而遗憾,不用郁闷,由CSDN打造的OpenStack技术峰会强势来袭了,5月15日,北京新云南皇冠假日酒店,我们邀请到众多O ...

最新文章

  1. ComponentOne Ultimate 2020中文版
  2. 为何Apache下.htaccess不起作用,Linux、Windows详解
  3. ORACLE下载当中的gateways,companion,clusterware都是什么用途?
  4. 数据库高级知识——主从复制
  5. Confluence 6 匿名访问远程 API
  6. linux中sed命令用例,sed解析和用例(马哥视频笔记)
  7. liunxs运维_Linux运维工程师必备(命令)
  8. SpringMVC 工作流程
  9. 如何安装 罗技“优联技术”无线鼠标、无线键盘?
  10. 【Vegas原创】VMWare下,Linux挂载、卸载新硬盘的方法
  11. poj1062 昂贵的聘礼
  12. 在MVC中使用泛型仓储模式和依赖注入实现增删查改
  13. 解决将visio图片插入Word后有大片空白
  14. 软件测试面试题目—接口测试面试题,梦寐以求的答案来了
  15. 对医疗类网站的seo优化方法细致探讨
  16. 计算机网络水晶头博客,网线水晶头接法顺序图解分享,这个简单口诀记好了(超实用)...
  17. IEEE Transactions on Vehicular Technology投稿经验分享-1
  18. win10系统 开启蓝牙服务器,Win10打开蓝牙的方法步骤详解
  19. 我的编程之路点滴记录(三)
  20. ubuntu18.04安装微信——简单操作

热门文章

  1. 如何配置三层交换机创建VLAN 3
  2. GARFIELD@04-14-2005
  3. Failed to connect to driver at XXXXXXx
  4. 解决git push 中remote: Permission to xxxxx.git denied to xxx. fatal: unable to access xxxx 403(转)
  5. KNN针对中文文本分类
  6. java海滩上有一,Java猴子分桃问题--三种算法
  7. 语音识别(三)——声学模型, 解码器技术
  8. linux修复u盘文件系统,linux下转换U盘文件系统
  9. 抽象工厂模式_抽象工厂模式
  10. iframe打印excel bold_搭载君正X1000E芯片 中盈SP7080激光打印机现已开售!