想要做亞馬遜刊登,首先你需要去了解亞馬遜的開發檔案:http://docs.developer.amazonservices.com/en_US/dev_guide/DG_IfNew.html
API的SDK網址:https://developer.amazonservices.com/csharpclients/
Feeds 檔案夾里是你需要呼叫的介面
下面直接上代碼
服務配置
private static MarketplaceWebServiceClient GetService()
{
const string applicationName = "AmazonAPIInterface";
const string applicationVersion = "2.0";
MarketplaceWebServiceConfig config = new MarketplaceWebServiceConfig
{
ServiceURL = "https://mws.amazonservices.jp"//日本站點
};
MarketplaceWebServiceClient service = new MarketplaceWebServiceClient(AccessKey, SecretKey, applicationName, applicationVersion, config);
return service;
}
構造產品
private static SubmitFeedRequest GetSubmitFeedRequest()
{
#region 產品資料
string USD = "USD";
StringBuilder sb = new StringBuilder();
sb.Append("<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>");
sb.Append("<AmazonEnvelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"amzn-envelope.xsd\">");
sb.Append("<Header>");
sb.Append("<DocumentVersion>1.01</DocumentVersion>");//版本
sb.Append("<MerchantIdentifier>M_EXAMPLE_123456</MerchantIdentifier>");
sb.Append("</Header>");
sb.Append("<MessageType>Product</MessageType>");
sb.Append("<PurgeAndReplace>false</PurgeAndReplace>");
sb.Append("<Message>");
sb.Append("<MessageID>1</MessageID>");
sb.Append("<OperationType>Create</OperationType>");
#region 產品
sb.Append("<Product>");
sb.Append("<SKU>121212</SKU>");//產品sku
sb.Append("<StandardProductID>");//標準產品ID
sb.Append("<Type>ASIN</Type>");//產品ASIN
sb.Append("<Value>B06ZYX7X29</Value>");//產品ASIN值
sb.Append("</StandardProductID>");
sb.Append("<ProductTaxCode>154834566</ProductTaxCode>");//產品稅代碼
#region 產品描述
sb.Append("<DescriptionData>");
sb.Append("<Title>This is a book</Title>");//產品標題-不為空
sb.Append("<Brand>ehuifheu</Brand>");//產品品牌-
sb.Append("<Description>This is a book but you know</Description>");//產品描述-不為空
sb.Append("<BulletPoint>wqdqwd B</BulletPoint>");//產品特性簡介。-不為空
sb.Append("<BulletPoint>fefew B</BulletPoint>");//產品特性簡介。
sb.Append("<MSRP currency='" + USD + "'>25.19</MSRP>");//產品零售價
sb.Append("<Manufacturer>dqwdwqd Pr</Manufacturer>");//制造商
sb.Append("<ItemType>example-item-typeefew</ItemType>");//產品型別
sb.Append("<ItemDimensions>fewfewfv</ItemDimensions>");//產品大小
sb.Append("<PackageDimensions>feewf</PackageDimensions>");//包的尺寸
sb.Append("<PackageWeight>wefwe</PackageWeight>");//包裹重量
sb.Append("<ShippingWeight>ttre</ShippingWeight>");//運輸重量
sb.Append("<MerchantCatalogNumber>fewf</MerchantCatalogNumber>");//商業產品目錄號-不為空
sb.Append("<MaxOrderQuantity>efwwe</MaxOrderQuantity>");//最大訂單數量
sb.Append("<SerialNumberRequired>wefewf</SerialNumberRequired>");//所需的序列號
sb.Append("<Prop65>grehtrh</Prop65>");//指示產品須受加州65號提案規管。
sb.Append("<LegalDisclaimer>grerwe</LegalDisclaimer>");//法律免責宣告
sb.Append("<MfrPartNumber>grrg</MfrPartNumber>");//生產商零件號
sb.Append("<SearchTerms>reger</SearchTerms>");//檢索專案
sb.Append("<PlatinumKeywords>wefewf</PlatinumKeywords>");//產品映射到自定義瀏覽節點結構中的節點的值
sb.Append("<Memorabilia>fewew</Memorabilia>");//產品是紀念品。
sb.Append("<Autographed>rgeerg</Autographed>");//產品是已簽名的專案
sb.Append("<UsedFor>gergre</UsedFor>");//產品的用途。影響產品在瀏覽節點結構中的位置
sb.Append("<OtherItemAttributes>ewrgfrewgre</OtherItemAttributes>");//其他專案屬性
sb.Append("<TargetAudience>grregre</TargetAudience>");//目標客戶
sb.Append("<SubjectContent>efwefgw</SubjectContent>");//主題內容
sb.Append("<IsGiftWrapAvailable>ergreg</IsGiftWrapAvailable>");//可以用禮品包裝嗎
sb.Append("<IsGiftMessageAvailable>ergerg</IsGiftMessageAvailable>");//有禮品資訊
sb.Append("<IsDiscontinuedByManufacturer>efwwef</IsDiscontinuedByManufacturer>");//被制造商停止生產
sb.Append("<MaxAggregateShipQuantity>wefwefw</MaxAggregateShipQuantity>");//最大船舶總數量
sb.Append("<Variation VariationTheme='size'></Variation>");
sb.Append("</DescriptionData>");//產品描述
#endregion
#endregion
#region 產品資料
sb.Append("<ProductData>");
sb.Append("<Health>");
sb.Append("<ProductType>");
sb.Append("<HealthMisc>");
sb.Append("<Ingredients>fgewrg</Ingredients>");
sb.Append("<Directions>fewewf</Directions>");
sb.Append("</HealthMisc>");
sb.Append("</ProductType>");
sb.Append("</Health>");
sb.Append("</ProductData>");
#endregion
sb.Append("</Product>");
sb.Append("</Message>");
sb.Append("</AmazonEnvelope>");
#endregion
string s = sb.ToString();
byte[] array = Encoding.ASCII.GetBytes(s);
Stream stream = new MemoryStream(array);
SubmitFeedRequest request = new SubmitFeedRequest
{
Merchant = SellerID,
MarketplaceIdList = new IdList(),
FeedType = "_POST_PRODUCT_DATA_"
};
request.MarketplaceIdList.Id = new List<string> { DeveloperAccountNumber };
request.FeedContent = stream;
request.ContentMD5 = MarketplaceWebServiceClient.CalculateContentMD5(request.FeedContent);
request.FeedContent.Position = 0;
return request;
}
請求資訊
private static GetFeedSubmissionListRequest FeedSubmissionListRequest(string feedSubmmissionId)
{
GetFeedSubmissionListRequest request = new GetFeedSubmissionListRequest
{
Merchant = SellerID,
FeedSubmissionIdList = new IdList()
};
request.FeedSubmissionIdList.Id = new List<string>(new string[] { feedSubmmissionId });
return request;
}
private static GetFeedSubmissionResultRequest FeedSubmissionResultRequest(string feedSubmmissionId)
{
GetFeedSubmissionResultRequest request = new GetFeedSubmissionResultRequest();
string path = feedSubmmissionId + ".xml";//保存結果至本地
FileStream stream = new FileStream(path, FileMode.OpenOrCreate, FileAccess.ReadWrite);
request.Merchant = SellerID;
request.FeedSubmissionId = feedSubmmissionId;
request.FeedSubmissionResult = stream;
return request;
}
public static string FeedSubmissionList(string feedSubmmissionId)
{
MarketplaceWebServiceClient service = GetService();
GetFeedSubmissionListRequest request = FeedSubmissionListRequest(feedSubmmissionId);
GetFeedSubmissionListResponse response = service.GetFeedSubmissionList(request);
var s = response;
return "";
}
public static void FeedSubmissionResults(string feedSubmmissionId)
{
MarketplaceWebServiceClient service = GetService();
GetFeedSubmissionResultRequest request = FeedSubmissionResultRequest(feedSubmmissionId);
GetFeedSubmissionResultResponse response = service.GetFeedSubmissionResult(request);
}
uj5u.com熱心網友回復:
開個博客,論壇不是這么用的uj5u.com熱心網友回復:
?? 用了挺久 沒怎么寫過轉載請註明出處,本文鏈接:https://www.uj5u.com/net/56921.html
標籤:ASP.NET
上一篇:用spring.net AdoTemplate訪問資料庫偶爾會提示Could not create ado.net connection for transca
