日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

eBay Notification介绍

發布時間:2023/12/19 编程问答 39 豆豆
生活随笔 收集整理的這篇文章主要介紹了 eBay Notification介绍 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

?

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

  • [Test]
  • public void SetNotification_EnableOrDisable_ApplicaitonDelivery_Test()
  • {
  • ????var context = ApiContextFactory.GetApiContext(token);
  • ????//var context = SandBoxEnvironment.GetApiContextOfSendBox();
  • ????SetNotificationPreferencesCall call = new SetNotificationPreferencesCall(context);
  • ????var enable = EnableCodeType.Enable;
  • ????var type = new ApplicationDeliveryPreferencesType()
  • ????{
  • ????????AlertEmail = "mailto://1050244110@qq.com",
  • ????????AlertEnable = enable,
  • ????????AlertEnableSpecified = true,
  • ????????ApplicationURL = "mailto://1050244110@qq.com",
  • ????????ApplicationEnable = enable,
  • ????????ApplicationEnableSpecified = true,
  • ????????DeliveryURLDetails = new DeliveryURLDetailTypeCollection(
  • ????????????new DeliveryURLDetailType[] {
  • ????????????new DeliveryURLDetailType()
  • ????????????{
  • ????????????????Status = enable,
  • ????????????????DeliveryURLName = "seller1_Delivery",
  • ????????????????DeliveryURL = "http://address1.com",
  • ????????????????StatusSpecified = true
  • ????????????},new DeliveryURLDetailType(){
  • ????????????????????Status = enable,
  • ????????????????????DeliveryURLName = "seller2_Delivery",
  • ????????????????????DeliveryURL = "http://address2.com",
  • ????????????????????StatusSpecified = true
  • ????????????}})
  • ????};
  • ????call.SetNotificationPreferences(type);
  • }
  • ?

    查看指定結果

  • [Test]
  • public void GetNotification_RoleCodeType_Application_Test()
  • {
  • ????var context = ApiContextFactory.GetApiContext(token);
  • ????//var context = SandBoxEnvironment.GetApiContextOfSendBox();
  • ????GetNotificationPreferencesCall call = new GetNotificationPreferencesCall(context);
  • ????call.GetNotificationPreferences(NotificationRoleCodeType.Application);
  • ????Console.WriteLine(call.ApplicationDeliveryPreferences);
  • ????Console.WriteLine(call.ApplicationDeliveryPreferences.AlertEmail);
  • ????Console.WriteLine(call.ApplicationDeliveryPreferences.ApplicationURL);
  • ????Console.WriteLine(call.ApplicationDeliveryPreferences.AlertEnable.ToString());
  • ????Console.WriteLine(call.ApplicationDeliveryPreferences.ApplicationEnable.ToString());
  • ????Console.WriteLine(call.ApplicationDeliveryPreferences.DeviceType.ToString());
  • ????Console.WriteLine(call.ApplicationDeliveryPreferences.NotificationPayloadType.ToString());
  • ????foreach (DeliveryURLDetailType item in call.ApplicationDeliveryPreferences.DeliveryURLDetails)
  • ????{
  • ????????Console.WriteLine(item.DeliveryURL);
  • ????????Console.WriteLine(item.DeliveryURLName);
  • ????????Console.WriteLine(item.Status.ToString());
  • ????}
  • }
  • ?

    ?

    2.3訂閱EventType

    ?

  • [Test]
  • public void SetNotificationPreferences_EnableOrDisbable_EventTypes()
  • {
  • ????var context = ApiContextFactory.GetApiContext(token);
  • ????//var context = SandBoxEnvironment.GetApiContextOfSendBox();
  • ????SetNotificationPreferencesCall call = new SetNotificationPreferencesCall(context);
  • ????var enable = EnableCodeType.Enable;
  • ????call.DeliveryURLName = "seller1_ Delivery "; //如果指定了,則使用對應名稱的URL,反之,則使用?ApplicationURL
  • ????var coll = new NotificationEnableTypeCollection();
  • ????coll.Add(new NotificationEnableType()
  • ????{
  • ????????EventEnable = enable,
  • ????????EventEnableSpecified = true,
  • ????????EventType = NotificationEventTypeCodeType.AuctionCheckoutComplete,
  • ????????EventTypeSpecified = true
  • ????});
  • ????coll.Add(new NotificationEnableType()
  • ????{
  • ????????EventEnable = enable,
  • ????????EventEnableSpecified = true,
  • ????????EventType = NotificationEventTypeCodeType.FixedPriceTransaction,
  • ????????EventTypeSpecified = true
  • ????});
  • ????coll.Add(new NotificationEnableType()
  • ????{
  • ????????EventEnable = enable,
  • ????????EventEnableSpecified = true,
  • ????????EventType = NotificationEventTypeCodeType.EndOfAuction,
  • ????????EventTypeSpecified = true
  • ????});
  • ????call.SetNotificationPreferences(coll);
  • }
  • ?

    查看訂閱結果

    ?

  • [Test]
  • public void GetNotification_UserLevel_Test()
  • {
  • ????var context = ApiContextFactory.GetApiContext(token);
  • ????//var context = SandBoxEnvironment.GetApiContextOfSendBox();
  • ????GetNotificationPreferencesCall call = new GetNotificationPreferencesCall(context);
  • ????call.GetNotificationPreferences(NotificationRoleCodeType.User);
  • ????Console.WriteLine(call.DeliveryURLName);
  • ????Console.WriteLine(call.DetailLevelList.Count);
  • ????foreach (NotificationEnableType item in call.UserDeliveryPreferenceList)
  • ????{
  • ????????Console.WriteLine(item.EventEnable.ToString());
  • ????????Console.WriteLine(item.EventType.ToString());
  • ????}
  • }
  • ?

    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介绍的全部內容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。