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

搜 索
首页>API开发者平台>技术文档>给商品添加图片的方法

技术文档

问题
给商品添加图片的方法
解答
0
人觉得答案有帮助)
总结

有三种可行的方法给商品附上图片: 

1. 使用SDK的内建特性上传图片,并将图片与商品一同列出。
2. 调用UploadSiteHostedPictures来上传图片,然后在AddItem请求中使用已上传图片的URL。  
3. 在你的域名上host图片,然后在AddItem请求中调用图片的URL。



详细说明

1.  使用SDK 

如果你使用了任何一种Java或Windows SDK,你就可以使用SDK的内建特性来上传图片。 

使用.NET SDK的例程: 

//Set the Picture Server URL for Sandbox 
context.EPSServerUrl = "https://api.sandbox.ebay.com/ws/api.dll";

//For production use this URL 
//context.EPSServerUrl = "https://api.ebay.com/ws/api.dll"; 

//Set file path of the picture on the local disk  

apicall.PictureFileList = new StringCollection(); 
//pic1.gif is uploaded for free 
apicall.PictureFileList.Add(@"
C://TEMP/pic1.gif"); 

//To specify a Gallery Image 
item.PictureDetails = new PictureDetailsType(); 
//The first picture is used for Gallery URL 
item.PictureDetails.GalleryType = GalleryTypeCodeType.Gallery; 

//To add more pictures 
apicall.PictureFileList.Add(@"
C://TEMP/pic2.gif");

使用 Java SDK的例程:

 //Set the Picture Server URL for Sandbox 
apiContext.setEpsServerUrl("https://api.sandbox.ebay.com/ws/api.dll"); 

//For production use this URL 
//apiContext.setEpsServerUrl("https://api.ebay.com/ws/api.dll"); 


//Set file path of the picture on the local disk  
//To add more pictures, specify the file paths in the pictureFiles array
 
String [] pictureFiles = {"C://TEMP/pic1.gif"}; 
api.setPictureFiles(pictureFiles); 

//To specify a Gallery Image 
PictureDetailsType pictureDetailsObj = new PictureDetailsType(); 
//The first picture is used for Gallery URL 
pictureDetailsObj.setGalleryTypeGalleryTypeCodeType.GALLERY); 
item.setPictureDetails(pictureDetailsObj);

 

2.  向eBay上传图片并在AddItem请求中使用 

调用UploadSiteHostedPictures API来上传图片:
http://developer.ebay.com/DevZone/XML/docs/Reference/eBay/UploadSiteHostedPictures.html 

下面展示了一些使用SDK添加图片的代码片段:

使用.NET SDK的例程:

item.PictureDetails = new PictureDetailsType(); 
item.PictureDetails.PictureURL = new StringCollection(); 
item.PictureDetails.PictureURL.Add("
/uploadfile/2010/1105/20101105113650362.jpg"); 
item.PictureDetails.PictureURL.Add("
/uploadfile/2010/1105/20101105113650799.jpg");

使用Java SDK的例程:

String [] pictureURLs = new String [2]; 
pictureURLs[0] = "
/uploadfile/2010/1105/20101105113650362.jpg"; 
pictureURLs[1] = "
/uploadfile/2010/1105/20101105113650799.jpg";      
            
PictureDetailsType pictureDetailsObj = new PictureDetailsType(); 
pictureDetailsObj.setPictureURL(pictureURLs); 

item.setPictureDetails(pictureDetailsObj);

AddItem XML请求的例程

<?xml version="1.0" encoding="utf-8"?>
<AddItemRequest xmlns="urn:ebay:apis:eBLBaseComponents"> 
  <Item>
    <!-- other required item fields -->
    <PictureDetails> 
     <PictureURL>http://i9.ebayimg.com/03/c/00/c1/51/8f_8.JPG</PictureURL>
      <PictureURL>http://i9.ebayimg.com/03/c/00/c1/51/8f_9.JPG</PictureURL>
    </PictureDetails>
  </Item>
  <RequesterCredentials xmlns="urn:ebay:apis:eBLBaseComponents">
    <eBayAuthToken>*****</eBayAuthToken>
  </RequesterCredentials>
</AddItemRequest>

 

3.  在你自己的域名上host图片 

如果你想要在自己的服务器上host图片,你可以在AddItem中设置图片的URL:

使用 .NET SDK的例程:
 

item.PictureDetails = new PictureDetailsType(); 
item.PictureDetails.PictureURL = new StringCollection(); 
item.PictureDetails.PictureURL.Add("
http://www.mydomain.com/picture1.jpg"); 
//To specify a Gallery Image 
item.PictureDetails.GalleryType = GalleryTypeCodeType.Gallery;

使用Java SDK的例程:

String [] pictureURLs = {""http://www.mydomain.com/picture1.jpg""};            
PictureDetailsType pictureDetailsObj = new PictureDetailsType(); 
pictureDetailsObj.setPictureURL(pictureURLs); 
//To specify a Gallery Image 
pictureDetailsObj.setGalleryType(GalleryTypeCodeType.GALLERY); 
item.setPictureDetails(pictureDetailsObj); 

 

答案对您有帮助吗?

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