eBay大中华区API开发者平台 开发者专区

搜 索
首页>API开发者平台>技术文档>如何设置Notification Preferences?

技术文档

问题
如何设置Notification Preferences?
解答
0
人觉得答案有帮助)
为了使注册用户获取Notification,你需要为每个用户都启用Notification功能。下面所列的JAVA代码片段使用了Java SDK来为Outbid和EOA设置Notification Preference。请注意,只有由eBayAuthToken代表的用户才能被设置Preference,因此你必须获取所有想要订阅的用户的有效 Token。生成的SOAP请求和响应也会被显示。 

// Setup the ApiContext 
String baseURL = "https://api.sandbox.ebay.com/wsapi"; 
String developerCode = "Set your DevCode"; 
String applicationCode = "Set your AppCode"; 
String certCode = "Set your CertCode"; 
String eBayToken = "Set the User's Token Here"; 
ApiContext apiContext = new ApiContext(); 
ApiAccount apiAccount = new ApiAccount(); 
ApiCredential apiCredential = new ApiCredential(); 

// Set apiAccount params 
apiAccount.setDeveloper(developerCode); 
apiAccount.setApplication(applicationCode); 
apiAccount.setCertificate(certCode); 

// Set apiCredential params 
apiCredential.seteBayToken(eBayToken); 
apiCredential.setApiAccount(apiAccount); 

// Set apiContext params 
apiContext.setApiCredential(apiCredential); 
apiContext.setApiServerUrl(baseURL); 

// turn on logging to standard out 
ApiLogging logging = new ApiLogging(); 
logging.setEnableLogging(true); 
logging.setLogSOAPMessages(true); 
logging.setLogExceptions(true); 
apiContext.setApiLogging(logging); 

// New SetNotificationPreferences Call 
SetNotificationPreferencesCall api = new SetNotificationPreferencesCall(apiContext); 

// Create and Set the User Level OutBid Preference 
NotificationEnableType OutBidEnable = new NotificationEnableType(); 
OutBidEnable.setEventEnable(EnableCodeType.Enable); 
OutBidEnable.setEventType(NotificationEventTypeCodeType.OutBid); 

// Create and Set the User Level EOA Preference 
NotificationEnableType EOAEnable = new NotificationEnableType(); 
EOAEnable.setEventEnable(EnableCodeType.Enable); 
EOAEnable.setEventType(NotificationEventTypeCodeType.EndOfAuction); 

// Create a NotificationEnableArrayType for the User Deliver Preferences 
NotificationEnableArrayType notifyEnableArray = new NotificationEnableArrayType(); 
api.setUserDeliveryPreferenceArray(notifyEnableArray); 
notifyEnableArray.setNotificationEnable(new NotificationEnableType[] { 
OutBidEnable, 
EOAEnable }); 

// Make the Call 
api.setNotificationPreferences(); 


SOAP LOG 
---------------------------------------------------------------------------------------------------------------------------------------- 
<?xml version="1.0" encoding="UTF-8"?> 
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 
<soapenv:Header> 
<ebl:RequesterCredentials soapenv:mustUnderstand="0" xmlns:ebl="urn:ebay:apis:eBLBaseComponents"> 
<ebl:eBayAuthToken xmlns:ebl="urn:ebay:apis:eBLBaseComponents">***</ebl:eBayAuthToken> 
</ebl:RequesterCredentials> 
<ebl:RequesterCredentials soapenv:mustUnderstand="0" xmlns:api="urn:ebay:apis:eBLBaseComponents" xmlns:ebl="urn:ebay:apis:eBLBaseComponents"> 
<ebl:Credentials xmlns:ebl="urn:ebay:apis:eBLBaseComponents"> 
<ebl:AppId xmlns:ebl="urn:ebay:apis:eBLBaseComponents">***</ebl:AppId> 
<ebl:DevId xmlns:ebl="urn:ebay:apis:eBLBaseComponents">***;</ebl:DevId> 
<ebl:AuthCert xmlns:ebl="urn:ebay:apis:eBLBaseComponents">***;</ebl:AuthCert> 
</ebl:Credentials> 
</ebl:RequesterCredentials> 
</soapenv:Header> 
<soapenv:Body> 
<SetNotificationPreferencesRequest xmlns="urn:ebay:apis:eBLBaseComponents"> 
<DetailLevel>ReturnAll</DetailLevel> 
<Version>549</Version> 
<UserDeliveryPreferenceArray> 
<NotificationEnable> 
<EventType>OutBid</EventType> 
<EventEnable>Enable</EventEnable> 
</NotificationEnable> 
<NotificationEnable> 
<EventType>EndOfAuction</EventType> 
<EventEnable>Enable</EventEnable> 
</NotificationEnable> 
</UserDeliveryPreferenceArray> 
</SetNotificationPreferencesRequest> 
</soapenv:Body> 
</soapenv:Envelope> 

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 
<soapenv:Body> 
<SetNotificationPreferencesResponse xmlns="urn:ebay:apis:eBLBaseComponents"> 
<Timestamp>2008-03-03T20:55:04.789Z</Timestamp> 
<Ack>Success</Ack> 
<CorrelationID>00000000-00000000-00000000-00000000-00000000-00000000-0000000000</CorrelationID> 
<Version>553</Version> 
<Build>e553_core_Bundled_6126319_R1</Build> 
</SetNotificationPreferencesResponse> 
</soapenv:Body> 
</soapenv:Envelope>

答案对您有帮助吗?

是,对我很有帮助
否,没解决我的问题