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.  
  8.     var enable = EnableCodeType.Enable;
  9.     var type = new ApplicationDeliveryPreferencesType()
  10.     {
  11.         AlertEmail = "mailto://1050244110@qq.com",
  12.         AlertEnable = enable,
  13.         AlertEnableSpecified = true,
  14.  
  15.         ApplicationURL = "mailto://1050244110@qq.com",
  16.         ApplicationEnable = enable,
  17.         ApplicationEnableSpecified = true,
  18.  
  19.         DeliveryURLDetails = new DeliveryURLDetailTypeCollection(
  20.             new DeliveryURLDetailType[] {
  21.             new DeliveryURLDetailType()
  22.             {
  23.                 Status = enable,
  24.                 DeliveryURLName = "seller1_Delivery",
  25.                 DeliveryURL = "http://address1.com",
  26.                 StatusSpecified = true
  27.             },new DeliveryURLDetailType(){
  28.                     Status = enable,
  29.                     DeliveryURLName = "seller2_Delivery",
  30.                     DeliveryURL = "http://address2.com",
  31.                     StatusSpecified = true
  32.             }})
  33.     };
  34.  
  35.     call.SetNotificationPreferences(type);
  36. }

 

查看指定结果

  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.  
  8.     var enable = EnableCodeType.Enable;
  9.     call.DeliveryURLName = "seller1_ Delivery "; //如果指定了,则使用对应名称的URL,反之,则使用 ApplicationURL
  10.     var coll = new NotificationEnableTypeCollection();
  11.  
  12.     coll.Add(new NotificationEnableType()
  13.     {
  14.         EventEnable = enable,
  15.         EventEnableSpecified = true,
  16.         EventType = NotificationEventTypeCodeType.AuctionCheckoutComplete,
  17.         EventTypeSpecified = true
  18.     });
  19.  
  20.     coll.Add(new NotificationEnableType()
  21.     {
  22.         EventEnable = enable,
  23.         EventEnableSpecified = true,
  24.         EventType = NotificationEventTypeCodeType.FixedPriceTransaction,
  25.         EventTypeSpecified = true
  26.     });
  27.  
  28.     coll.Add(new NotificationEnableType()
  29.     {
  30.         EventEnable = enable,
  31.         EventEnableSpecified = true,
  32.         EventType = NotificationEventTypeCodeType.EndOfAuction,
  33.         EventTypeSpecified = true
  34.     });
  35.  
  36.  
  37.     call.SetNotificationPreferences(coll);
  38. }

 

查看订阅结果

 

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

 

2.4 邮件接收结果截图

内容就是XML文档。

3.注意事项

3.1 端口

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

3.2 token

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

3.3 ApplicationDeliveryPreferencesType

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

eBay Notification介绍的更多相关文章

  1. Android之Notification介绍

    Notification就是在桌面的状态通知栏.这主要涉及三个主要类: Notification:设置通知的各个属性. NotificationManager:负责发送通知和取消通知 Notifica ...

  2. android Notification介绍

    如果要添加一个Notification,可以按照以下几个步骤 1:获取NotificationManager: NotificationManager m_NotificationManager=(N ...

  3. Rxjs中Notification 介绍

    timer(0, 1000) // 计时器,每1000ms发射一个值,初始发射值延迟时间为0s: .pipe( take(5), // 取前5个值 takeWhile(value => valu ...

  4. Android Notification 版本适配方案

    Notification 介绍见:https://developer.android.com/reference/android/app/Notification.html Android api 一 ...

  5. Android学习笔记总结

    第一步: Android(1) - 在 Windows 下搭建 Android 开发环境,以及 Hello World 程序 搭建 Android 的开发环境,以及写一个简单的示例程序 · 在 Win ...

  6. Jenkis Editable Email Notification Plugin 使用介绍

    Jenkis Editable Email Notification Plugin 使用介绍 前言 Jenkins本身提供的Email插件功能实在有限,只能提供当前Job的基本信息,比如成功.失败以及 ...

  7. Apache DolphinScheduler 架构演进介绍及开源经验分享 - eBay 阮文俊

    引言 来自 eBay 的文俊同学在近期的上海开源大数据 Meetup 上做了十分精彩的 "Apache DolphinScheduler 的架构演进" 分享.本次分享有近 200 ...

  8. 使用eBay API基本步骤介绍

    要开始使用eBay API,需要如下基本步骤: 1.    注册开发帐号: https://developer.ebay.com/join/Default.aspx 2.    选择API类型: eB ...

  9. 介绍一个比较酷东西:HTML5 桌面通知(Notification API)

    Notification API 是 HTML5 新增的桌面通知 API,用于向用户显示通知信息.该通知是脱离浏览器的,即使用户没有停留在当前标签页,甚至最小化了浏览器,该通知信息也一样会置顶显示出来 ...

随机推荐

  1. show slave各项参数解释

    how slave status 各个参数的解释 -- mysql 分类: mysql基础2012-08-23 11:03 2315人阅读 评论(0) 收藏 举报 服务器sslfilesqltable ...

  2. [Effective JavaScript 笔记] 第4条:原始类型优于封闭对象

    js有5种原始值类型:布尔值.数字.字符串.null和undefined. 用typeof检测一下: typeof true; //"boolean" typeof 2; //&q ...

  3. 教程Xcode 4下编译发布与提交App到AppStore

    地址:http://www.cocoachina.com/bbs/simple/?t55825.html 教程Xcode 4下编译发布与提交App到AppStore 先说一下这个是我在网上看到的一个帖 ...

  4. 在pc游览器端模拟移动端幻灯片

    用简单的思路写了下pc端模拟web端的图片滑动效果... 效果卡,bug多,完毕,继续学习c3方法写这个,iscroll就是可以模拟这种效果,还在学习中,难点<触点判断> 代码一份 < ...

  5. Linux&shell之高级Shell脚本编程-创建函数

    写在前面:案例.常用.归类.解释说明.(By Jim) 使用函数 #!/bin/bash # testing the script function myfun { echo "This i ...

  6. 《ASP.NET MVC4 WEB编程》学习笔记------HtmlHelper

    本文转载自powerzhang,如果给您带来不便请联系博主. 在实际的程序中,除了在View中展示数据外,还需要在View与后台的数据进行交互,在View中我就需要用的表单相关的元素: 在MVC3框架 ...

  7. Subarray Sum & Maximum Size Subarray Sum Equals K

    Subarray Sum Given an integer array, find a subarray where the sum of numbers is zero. Your code sho ...

  8. Android app主线程UI更新间歇性崩溃的问题

    对App进行开发测试时,偶尔出现app崩溃的问题.日志如下: 10-25 18:44:52.935 15290-15290/com.zzq.cnblogs E/AndroidRuntime﹕ FATA ...

  9. 当年的文曲星cc800

    你还记得当年的cc800吗?还记得黄金英雄传说吗?还记得用cc800编程的日子吗... 今天突然想起了我的cc800,好怀念那段爬在家里的阳台的木架子上,挠着头,编程序的日子...可惜,当时比较穷,没 ...

  10. Android数据存储之sharedpreferences与Content Provider

    android中对数据操作包含有: file, sqlite3, Preferences, ContectResolver与ContentProvider前三种数据操作方式都只是针对本应用内数据,程序 ...