?
1. Introduction
"Notification Service" (the contract is the Chinese name of notification), is a convenient tool provided by EBAYAPI, with real-time characteristics.
?
Its design idea is based on the publish-subscribe model. Once a client subscribes to an event that requires notification, the client receives a notification from ebay in real time when the server sends a notification.
?
Official API Documentation:
http://developer.ebay.com/Devzone/guides/ebayfeatures/Notifications/Notifications.html This document should be the best first-hand information.
?
Forum Posts:
http://community.ebay.cn/thread-1200288175-1-1.html This post is more comprehensive.
?
. NET WebService Receive Example:
https://ebaydts.com/eBayKBDetails?KBid=2112 can be used directly, mainly in the configuration of SOAP message reception.
2.Usage
2.1 Process Description
1) Use the Setnotificationpreference interface to set the event type, notification address (email or URL) of the subscription
2) If you choose email, just consider how you will handle it after you receive the email.
3) If you choose a URL, you need to provide an address, such as Ebayapi.company.com's address to receive, here Note that the port number as far as possible to use 80 (8080 and 443 have not tried, should be able to), but the use of 94, the results are not received. Asked about ebay's technology, only with the default port.
4) When an event with a subscription occurs, ebay will proactively push the message to your pre-set notification address.
?
2.2 Setting the Receive address
?
Mainly divided into wake-up mailbox Settings , the default receive URL, a specified URL(up to 25) three blocks.
Alertemail,applicationurl,deliveryurldetailtype, in turn, respectively.
- [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://[email protected]",
- ???????? Alertenable = Enable,
- ???????? Alertenablespecified = true,
- ?
- ???????? ApplicationUrl = "mailto://[email protected]",
- ???????? 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);
- }
?
View specified results
- [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 Subscribe to 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 "; //If specified, use the URL of the corresponding name, or vice versa. 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);
- }
?
View Subscription Results
?
- [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 Mail Receive results
The content is an XML document.
3. Precautions
3.1 Ports
If using HTTP or HTTPS, the port number should use the default port number (80,443) as far as possible
3.2 Token
When subscribing to a seller's eventtype, it is necessary to specify the token of the seller;
3.3 Applicationdeliverypreferencestype
When Applicationdeliverypreferencestype is set to disable, all enabled subscription events are not sent unless they are also set to enable.
EBay Notification Introduction