public static void Main(string[] args) { var chain = new CredentialProfileStoreChain(); AWSCredentials awsCredentials; chain.TryGetAWSCredentials("RedCarpet MWS", out awsCredentials); var creds = awsCredentials.GetCredentials(); // Developer AWS access key string accessKey = creds.AccessKey; // Developer AWS secret key string secretKey = creds.SecretKey; // The client application name string appName = "CSharpSampleCode"; // The client application version string appVersion = "1.0"; // The endpoint for region service and version (see developer guide) // ex: https://mws.amazonservices.com string serviceURL = "https://mws.amazonservices.com"; // Create a configuration object MarketplaceWebServiceProductsConfig config = new MarketplaceWebServiceProductsConfig(); config.ServiceURL = serviceURL; // Set other client connection configurations here if needed // Create the client itself IMarketplaceWebServiceProducts client = new MarketplaceWebServiceProductsClient(appName, appVersion, accessKey, secretKey, config); MarketplaceWebServiceProductsSample sample = new MarketplaceWebServiceProductsSample(client); // Uncomment the operation you'd like to test here // TODO: Modify the request created in the Invoke method to be valid try { IMWSResponse response = null; //response = sample.InvokeGetCompetitivePricingForASIN(); // response = sample.InvokeGetCompetitivePricingForSKU(); // response = sample.InvokeGetLowestOfferListingsForASIN(); // response = sample.InvokeGetLowestOfferListingsForSKU(); // response = sample.InvokeGetLowestPricedOffersForASIN(); // response = sample.InvokeGetLowestPricedOffersForSKU(); // response = sample.InvokeGetMatchingProduct(); // response = sample.InvokeGetMatchingProductForId(); response = sample.InvokeGetMyFeesEstimate(); // response = sample.InvokeGetMyPriceForASIN(); // response = sample.InvokeGetMyPriceForSKU(); // response = sample.InvokeGetProductCategoriesForASIN(); // response = sample.InvokeGetProductCategoriesForSKU(); // response = sample.InvokeGetServiceStatus(); // response = sample.InvokeListMatchingProducts(); Console.WriteLine("Response:"); ResponseHeaderMetadata rhmd = response.ResponseHeaderMetadata; // We recommend logging the request id and timestamp of every call. Console.WriteLine("RequestId: " + rhmd.RequestId); Console.WriteLine("Timestamp: " + rhmd.Timestamp); string responseXml = response.ToXML(); Console.WriteLine(responseXml); } catch (MarketplaceWebServiceProductsException ex) { // Exception properties are important for diagnostics. ResponseHeaderMetadata rhmd = ex.ResponseHeaderMetadata; Console.WriteLine("Service Exception:"); if(rhmd != null) { Console.WriteLine("RequestId: " + rhmd.RequestId); Console.WriteLine("Timestamp: " + rhmd.Timestamp); } Console.WriteLine("Message: " + ex.Message); Console.WriteLine("StatusCode: " + ex.StatusCode); Console.WriteLine("ErrorCode: " + ex.ErrorCode); Console.WriteLine("ErrorType: " + ex.ErrorType); throw ex; } }
public static void GetSkuPrice(Dictionary<string, Dictionary<string, float>> skuDict) { // Create a configuration object MarketplaceWebServiceProductsConfig config = new MarketplaceWebServiceProductsConfig(); config.ServiceURL = GlobalConfig.Instance.ServiceURL; // Set other client connection configurations here if needed // Create the client itself MarketplaceWebServiceProducts client = new MarketplaceWebServiceProductsClient(GlobalConfig.Instance.AppName, GlobalConfig.Instance.AppVersion, GlobalConfig.Instance.AccessKey, GlobalConfig.Instance.SecretKey, config); MarketplaceWebServiceProductsSample sample = new MarketplaceWebServiceProductsSample(client, GlobalConfig.Instance.SellerId, "", GlobalConfig.Instance.MarketplaceId); // Uncomment the operation you'd like to test here // TODO: Modify the request created in the Invoke method to be valid try { //*** todo: ������Ҫ��list����Ƭ��ÿ��20�� List<string> skuList = new List<string>(skuDict.Keys); IMWSResponse response = null; int count = GlobalConfig.Instance.SkuPriceCount; int current_index; for (current_index = 0; current_index < skuList.Count; current_index += count){ int current_count = (current_index + count) > skuList.Count ? skuList.Count - current_index : count; List<string> skuRangeList = skuList.GetRange(current_index, current_count); //{ // // ��ȡ���ﳵ�۸� // response = sample.InvokeGetCompetitivePricingForSKU(skuRangeList); // XmlDocument xmlDocument = new XmlDocument(); // xmlDocument.LoadXml(response.ToXML()); // XmlNamespaceManager nsmgr = new XmlNamespaceManager(xmlDocument.NameTable); // nsmgr.AddNamespace("mws", xmlDocument.GetElementsByTagName("GetCompetitivePricingForSKUResponse")[0].Attributes["xmlns"].Value); // XmlNodeList xnList = xmlDocument.SelectNodes("//mws:GetCompetitivePricingForSKUResult", nsmgr); // foreach (XmlNode xn in xnList) // { // string competitive_price = xn.SelectSingleNode(".//mws:LandedPrice/mws:Amount", nsmgr).InnerText; // skuDict[xn.Attributes["SellerSKU"].Value].Add("competitive_price", float.Parse(competitive_price)); // } //} // ��ȡ��ǰ��ͼ� { response = sample.InvokeGetLowestOfferListingsForSKU(skuRangeList); XmlDocument xmlDocument = new XmlDocument(); xmlDocument.LoadXml(response.ToXML()); XmlNamespaceManager nsmgr = new XmlNamespaceManager(xmlDocument.NameTable); nsmgr.AddNamespace("mws", xmlDocument.GetElementsByTagName("GetLowestOfferListingsForSKUResponse")[0].Attributes["xmlns"].Value); XmlNodeList xnList = xmlDocument.SelectNodes("//mws:GetLowestOfferListingsForSKUResult", nsmgr); foreach (XmlNode xn in xnList) { XmlNode target = xn.SelectSingleNode(".//mws:LandedPrice/mws:Amount", nsmgr); if (target != null) { string lowest_price = target.InnerText; skuDict[xn.Attributes["SellerSKU"].Value].Add("lowest_price", float.Parse(lowest_price)); } } } // ��ȡ�ҵļ۸� { response = sample.InvokeGetMyPriceForSKU(skuRangeList); XmlDocument xmlDocument = new XmlDocument(); xmlDocument.LoadXml(response.ToXML()); XmlNamespaceManager nsmgr = new XmlNamespaceManager(xmlDocument.NameTable); nsmgr.AddNamespace("mws", xmlDocument.GetElementsByTagName("GetMyPriceForSKUResponse")[0].Attributes["xmlns"].Value); XmlNodeList xnList = xmlDocument.SelectNodes("//mws:GetMyPriceForSKUResult", nsmgr); foreach (XmlNode xn in xnList) { XmlNode target = xn.SelectSingleNode(".//mws:LandedPrice/mws:Amount", nsmgr); if (target != null) { string my_price = target.InnerText; skuDict[xn.Attributes["SellerSKU"].Value].Add("my_price", float.Parse(my_price)); } } } // Restore rate: 10 items every second System.Threading.Thread.Sleep(GlobalConfig.Instance.SkuPriceWaitTime); } ////ȡ����� ////*** todo: ��ȡ���ﳵ��sellerId���ж��Լ��Ƿ��������ﳵ ////XmlNodeList xnList = xmlDocument.GetElementsByTagName("GetCompetitivePricingForSKUResult"); //// response = sample.InvokeGetCompetitivePricingForASIN(); //// response = sample.InvokeGetCompetitivePricingForSKU(); //// response = sample.InvokeGetLowestOfferListingsForASIN(); //// response = sample.InvokeGetLowestOfferListingsForSKU(); //// response = sample.InvokeGetMatchingProduct(); //// response = sample.InvokeGetMatchingProductForId(); //// response = sample.InvokeGetMyPriceForASIN(); //// response = sample.InvokeGetMyPriceForSKU(); //// response = sample.InvokeGetProductCategoriesForASIN(); //// response = sample.InvokeGetProductCategoriesForSKU(); //// response = sample.InvokeGetServiceStatus(); //// response = sample.InvokeListMatchingProducts(); //Console.WriteLine("Response:"); //ResponseHeaderMetadata rhmd = response.ResponseHeaderMetadata; //// We recommend logging the request id and timestamp of every call. //Console.WriteLine("RequestId: " + rhmd.RequestId); //Console.WriteLine("Timestamp: " + rhmd.Timestamp); //string responseXml = response.ToXML(); //Console.WriteLine(responseXml); } catch (MarketplaceWebServiceProductsException ex) { // Exception properties are important for diagnostics. ResponseHeaderMetadata rhmd = ex.ResponseHeaderMetadata; Console.WriteLine("Service Exception:"); if(rhmd != null) { Console.WriteLine("RequestId: " + rhmd.RequestId); Console.WriteLine("Timestamp: " + rhmd.Timestamp); } Console.WriteLine("Message: " + ex.Message); Console.WriteLine("StatusCode: " + ex.StatusCode); Console.WriteLine("ErrorCode: " + ex.ErrorCode); Console.WriteLine("ErrorType: " + ex.ErrorType); throw ex; } }
// ������ public static void GetNumberOfOfferListings(string market_id, Dictionary<string, int> skuDict) { // Create a configuration object MarketplaceWebServiceProductsConfig config = new MarketplaceWebServiceProductsConfig(); config.ServiceURL = GlobalConfig.Instance.GetConfigValue(market_id, "serviceURL"); // Set other client connection configurations here if needed // Create the client itself //MarketplaceWebServiceProducts client = new MarketplaceWebServiceProductsClient(GlobalConfig.Instance.AppName, GlobalConfig.Instance.AppVersion, GlobalConfig.Instance.AccessKey, GlobalConfig.Instance.SecretKey, config); MarketplaceWebServiceProducts client = new MarketplaceWebServiceProductsClient(GlobalConfig.Instance.GetCommonConfigValue("appName"), GlobalConfig.Instance.GetCommonConfigValue("appVersion"), GlobalConfig.Instance.GetConfigValue(market_id, "accessKey"), GlobalConfig.Instance.GetConfigValue(market_id, "secretKey"), config); //MarketplaceWebServiceProductsSample sample = new MarketplaceWebServiceProductsSample(client, GlobalConfig.Instance.SellerId, "", GlobalConfig.Instance.MarketplaceId); MarketplaceWebServiceProductsSample sample = new MarketplaceWebServiceProductsSample(client, GlobalConfig.Instance.GetConfigValue(market_id, "sellerId"), "", GlobalConfig.Instance.GetConfigValue(market_id, "marketplaceId")); // Uncomment the operation you'd like to test here // TODO: Modify the request created in the Invoke method to be valid try { //*** todo: ������Ҫ��list����Ƭ��ÿ��20�� List<string> skuList = new List<string>(skuDict.Keys); IMWSResponse response = null; int count = int.Parse(GlobalConfig.Instance.GetCommonConfigValue("skuPriceCount")); int current_index; for (current_index = 0; current_index < skuList.Count; current_index += count) { int current_count = (current_index + count) > skuList.Count ? skuList.Count - current_index : count; List<string> skuRangeList = skuList.GetRange(current_index, current_count); { response = sample.InvokeGetCompetitivePricingForSKU(skuRangeList); XmlDocument xmlDocument = new XmlDocument(); xmlDocument.LoadXml(response.ToXML()); XmlNamespaceManager nsmgr = new XmlNamespaceManager(xmlDocument.NameTable); nsmgr.AddNamespace("mws", xmlDocument.GetElementsByTagName("GetCompetitivePricingForSKUResponse")[0].Attributes["xmlns"].Value); XmlNodeList xnList = xmlDocument.SelectNodes("//mws:GetCompetitivePricingForSKUResult", nsmgr); foreach (XmlNode xn in xnList) { //XmlNode target = xn.SelectSingleNode(".//mws:NumberOfOfferListings/mws:OfferListingCount", nsmgr); XmlNodeList xnListTarget = xn.SelectNodes(".//mws:NumberOfOfferListings/mws:OfferListingCount", nsmgr); foreach (XmlNode xnTarget in xnListTarget) { if (xnTarget.Attributes["condition"].Value == "New") { skuDict[xn.Attributes["SellerSKU"].Value] = int.Parse(xnTarget.InnerText); break; } } } } // Restore rate: 10 items every second System.Threading.Thread.Sleep(int.Parse(GlobalConfig.Instance.GetCommonConfigValue("skuPriceWaitTime"))); } } catch (MarketplaceWebServiceProductsException ex) { // Exception properties are important for diagnostics. ResponseHeaderMetadata rhmd = ex.ResponseHeaderMetadata; Console.WriteLine("Service Exception:"); if (rhmd != null) { Console.WriteLine("RequestId: " + rhmd.RequestId); Console.WriteLine("Timestamp: " + rhmd.Timestamp); } Console.WriteLine("Message: " + ex.Message); Console.WriteLine("StatusCode: " + ex.StatusCode); Console.WriteLine("ErrorCode: " + ex.ErrorCode); Console.WriteLine("ErrorType: " + ex.ErrorType); throw ex; } }
public static void xMain(string[] args) { // TODO: Set the below configuration variables before attempting to run // Developer AWS access key string accessKey = "replaceWithAccessKey"; // Developer AWS secret key string secretKey = "replaceWithSecretKey"; // The client application name string appName = "CSharpSampleCode"; // The client application version string appVersion = "1.0"; // The endpoint for region service and version (see developer guide) // ex: https://mws.amazonservices.com string serviceURL = "replaceWithServiceURL"; // Create a configuration object MarketplaceWebServiceProductsConfig config = new MarketplaceWebServiceProductsConfig(); config.ServiceURL = serviceURL; // Set other client connection configurations here if needed // Create the client itself MarketplaceWebServiceProducts client = new MarketplaceWebServiceProductsClient(appName, appVersion, accessKey, secretKey, config); MarketplaceWebServiceProductsSample sample = new MarketplaceWebServiceProductsSample(client); // Uncomment the operation you'd like to test here // TODO: Modify the request created in the Invoke method to be valid try { IMWSResponse response = null; // response = sample.InvokeGetCompetitivePricingForASIN(); // response = sample.InvokeGetCompetitivePricingForSKU(); // response = sample.InvokeGetLowestOfferListingsForASIN(); // response = sample.InvokeGetLowestOfferListingsForSKU(); // response = sample.InvokeGetLowestPricedOffersForASIN(); // response = sample.InvokeGetLowestPricedOffersForSKU(); // response = sample.InvokeGetMatchingProduct(); // response = sample.InvokeGetMatchingProductForId(); // response = sample.InvokeGetMyPriceForASIN(); // response = sample.InvokeGetMyPriceForSKU(); // response = sample.InvokeGetProductCategoriesForASIN(); // response = sample.InvokeGetProductCategoriesForSKU(); // response = sample.InvokeGetServiceStatus(); // response = sample.InvokeListMatchingProducts(); Console.WriteLine("Response:"); ResponseHeaderMetadata rhmd = response.ResponseHeaderMetadata; // We recommend logging the request id and timestamp of every call. Console.WriteLine("RequestId: " + rhmd.RequestId); Console.WriteLine("Timestamp: " + rhmd.Timestamp); string responseXml = response.ToXML(); Console.WriteLine(responseXml); } catch (MarketplaceWebServiceProductsException ex) { // Exception properties are important for diagnostics. ResponseHeaderMetadata rhmd = ex.ResponseHeaderMetadata; Console.WriteLine("Service Exception:"); if(rhmd != null) { Console.WriteLine("RequestId: " + rhmd.RequestId); Console.WriteLine("Timestamp: " + rhmd.Timestamp); } Console.WriteLine("Message: " + ex.Message); Console.WriteLine("StatusCode: " + ex.StatusCode); Console.WriteLine("ErrorCode: " + ex.ErrorCode); Console.WriteLine("ErrorType: " + ex.ErrorType); throw ex; } }
public static void Main(string[] args) { // TODO: Set the below configuration variables before attempting to run // Developer AWS access key string accessKey = "AKIAJ5Z2SMI4J7BZAFTA"; // Developer AWS secret key string secretKey = "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"; // The client application name string appName = "Baio Sucks"; // The client application version string appVersion = "1.0"; // The endpoint for region service and version (see developer guide) // ex: https://mws.amazonservices.com string serviceURL = "https://mws.amazonservices.com"; // Create a configuration object MarketplaceWebServiceProductsConfig config = new MarketplaceWebServiceProductsConfig(); config.ServiceURL = serviceURL; // Set other client connection configurations here if needed // Create the client itself MarketplaceWebServiceProducts client = new MarketplaceWebServiceProductsClient(appName, appVersion, accessKey, secretKey, config); MarketplaceWebServiceProductsSample sample = new MarketplaceWebServiceProductsSample(client); // Uncomment the operation you'd like to test here // TODO: Modify the request created in the Invoke method to be valid try { IMWSResponse response = null; // response = sample.InvokeGetCompetitivePricingForASIN(); // response = sample.InvokeGetCompetitivePricingForSKU(); // response = sample.InvokeGetLowestOfferListingsForASIN(); // response = sample.InvokeGetLowestOfferListingsForSKU(); // response = sample.InvokeGetLowestPricedOffersForASIN(); // response = sample.InvokeGetLowestPricedOffersForSKU(); //response = sample.InvokeGetMatchingProduct(); // response = sample.InvokeGetMatchingProductForId(); // response = sample.InvokeGetMyFeesEstimate(); // response = sample.InvokeGetMyPriceForASIN(); // response = sample.InvokeGetMyPriceForSKU(); // response = sample.InvokeGetProductCategoriesForASIN(); // response = sample.InvokeGetProductCategoriesForSKU(); //response = sample.InvokeGetServiceStatus(); response = sample.InvokeListMatchingProducts(); Console.WriteLine("Response:"); ResponseHeaderMetadata rhmd = response.ResponseHeaderMetadata; // We recommend logging the request id and timestamp of every call. Console.WriteLine("RequestId: " + rhmd.RequestId); Console.WriteLine("Timestamp: " + rhmd.Timestamp); string responseXml = response.ToXML(); Console.WriteLine(responseXml); Console.ReadLine(); } catch (MarketplaceWebServiceProductsException ex) { // Exception properties are important for diagnostics. ResponseHeaderMetadata rhmd = ex.ResponseHeaderMetadata; Console.WriteLine("Service Exception:"); if (rhmd != null) { Console.WriteLine("RequestId: " + rhmd.RequestId); Console.WriteLine("Timestamp: " + rhmd.Timestamp); } Console.WriteLine("Message: " + ex.Message); Console.WriteLine("StatusCode: " + ex.StatusCode); Console.WriteLine("ErrorCode: " + ex.ErrorCode); Console.WriteLine("ErrorType: " + ex.ErrorType); throw ex; } }