简体   繁体   English

如何使用eBay API将图像添加到现有项目

[英]How to add images to existing item with ebay API

I am using ebay-sdk for python. 我正在为Python使用ebay-sdk。 I uploaded some images to eBay Picture Services(EPS) successfully using the below code: 我使用以下代码成功将一些图像上传到了eBay图片服务(EPS):

from ebaysdk.trading import Connection as Trading

api = Trading(config_file='ebay.yaml', siteid=71)


def upload_images(image_url):
    response = api.execute('UploadSiteHostedPictures', {"ExternalPictureURL": image_url,
                                                             "PictureSet": "Supersize"})
    return response.content

upload_images(MY_IMG_URL)

eBay returns the URL of the uploaded images. eBay返回上传图像的URL。

But how can I add the images to my existing eBay offers? 但是,如何将图像添加到现有的eBay优惠中? Do I have to use ReviseItem? 我必须使用ReviseItem吗?

An example using the ebay-sdk for python would be nice. 将ebay-sdk用于python的示例很好。

Edit: 编辑:

    def revise_image(self, item_id):
    myitem = {
        "Item": {
            "Country": "DE",
            "ItemID": item_id,
            "PictureDetails": [
                {"PictureURL": MY_IMG1},
                {"PictureURL": MY_IMG2},
                {"PictureURL": MY_IMG3}
            ]
        }
    }
    response = self.api.execute('ReviseFixedPriceItem', myitem)

I made the changes as suggested but it still only changes the main image. 我按照建议进行了更改,但它仍然只更改了主图像。 MY_IMG3 becomes the main image. MY_IMG3成为主映像。 MY_IMG1 and MY_IMG2 are not appended to the listing. 清单未附加MY_IMG1和MY_IMG2。

This works. 这可行。

def verifyAddItem(args):
        #"""http://www.utilities-online.info/xmltojson/#.UXli2it4avc   """
    try:
        api = Trading(debug=args.debug, siteid=site_id, appid=app_id, token=token_id, config_file=None, certid=cert_id, devid=dev_id)

        myitem = {
            "Item": {
                "Country": "GB",
                "Description": description,
                "ItemID": item_to_revise,
                "PictureDetails": {
                    "PictureURL": "http://www.itcircleconsult.com/eb2017/4a.png"
                    },
                }
            }

        api.execute('ReviseFixedPriceItem', myitem)
        dump(api)

I have been working a lot with eBay and Python.. 我一直在eBay和Python上工作很多。

Check here for some working examples.. I often rip them apart and put them back together on the fly but you might find some use.. 在这里查看一些工作示例。.我经常将它们拆开,然后迅速将它们放回一起,但您可能会发现一些用处。

There is an I-ways checker and some BS4 ripping to revise items as well 有一个I-way Checker和一些BS4翻录以修改项目

https://github.com/johnashu/PRODUCTION/tree/master/Python/eBay%20API%20KIT%20-%20Maffas%20-%202017 https://github.com/johnashu/PRODUCTION/tree/master/Python/eBay%20API%20KIT%20-%20Maffas%20-%202017

another useful thing is check out the eBay API call index here: 另一个有用的事情是在这里查看eBay API调用索引:

http://developer.ebay.com/devzone/xml/docs/Reference/eBay/index.html#CallIndex http://developer.ebay.com/devzone/xml/docs/Reference/eBay/index.html#CallIndex

then use an XML to JSON convertor to change the calls you need into a more readable format in pythong.. 然后使用XML转JSON转换器将所需的调用更改为pythong中更易读的格式。

Here: 这里:

http://www.utilities-online.info/xmltojson/#.WTW_P8b-vct http://www.utilities-online.info/xmltojson/#.WTW_P8b-vct

NOTES ON ADDING IMAGES AND HOSTING: 有关添加图像和主持的注意事项:

https://developer.ebay.com/devzone/xml/docs/reference/ebay/UploadSiteHostedPictures.html https://developer.ebay.com/devzone/xml/docs/reference/ebay/UploadSiteHostedPictures.html

Note: As of release 889, you do not need to use this call to upload self-hosted images before creating the listing. 注意:从889版开始,在创建列表之前,无需使用此调用来上传自托管图像。 You can now specify up to 12 self-hosted or EPS hosted URLs at once in Item.PictureDetails.PictureURL using the AddItem or AddFixedPriceItem calls. 现在,您可以使用AddItem或AddFixedPriceItem调用在Item.PictureDetails.PictureURL中一次最多指定12个自托管或EPS托管URL。 However, you must use the UploadSiteHostedPictures call to upload binary attachments. 但是,您必须使用UploadSiteHostedPictures调用来上传二进制附件。

The supposed JSON needed it this.. unless it takes time to populate the pictures to the item? 假定的JSON需要此功能..除非需要花费一些时间将图片填充到项目中?

We were both Missing [] - Schoolboy error! 我们俩都[失踪]-小学生错误!

{
"Item": {
    "PictureDetails": [
    { "PictureURL": "http://pics.ebay.com/aw/pics/dot_clear.gif" },
    { "PictureURL": "fds" },
    { "PictureURL": "fds" }
    ]
}
}

I know this question is quite old, but I stumbled across this page because I ran into the same problem and found the correct solution. 我知道这个问题已经很老了,但是我偶然发现了这个页面,因为我遇到了同样的问题并找到了正确的解决方案。

As mentioned in the comments above, the currently posted solution by johnashu does not work. 如以上评论所述,johnashu当前发布的解决方案不起作用。 This is because of the way ebaysdk.utils.dict2xml converts dictionaries. 这是因为ebaysdk.utils.dict2xml转换字典的方式。

The above solution of: 上面的解决方案:

{
"Item": {
    "PictureDetails": [
    { "PictureURL": "http://pics.ebay.com/aw/pics/dot_clear.gif" },
    { "PictureURL": "fds" },
    { "PictureURL": "fds" }
    ]
}
}

Outputs XML of: 输出以下XML:

<Item>
  <PictureDetails>
    <PictureURL>http://pics.ebay.com/aw/pics/dot_clear.gif</PictureURL>
  </PictureDetails>
  <PictureDetails>
    <PictureURL>fds</PictureURL>
  </PictureDetails>
  <PictureDetails>
    <PictureURL>fds</PictureURL>
  </PictureDetails>
</Item>

Which includes multiple <PictureDetails> rather than one parent tag, with multiple PictureURL tags as children. 其中包括多个<PictureDetails>而不是一个父标记,并且多个PictureURL标记作为子标记。

The correct format is: 正确的格式是:

{
  "Item": {
    "PictureDetails": {
      'PictureURL': ['http://pics.ebay.com/aw/pics/dot_clear.gif', 'fds', 'fds']
    }
  }
}

Which gives us an XML output of: 这使我们的XML输出为:

<Item>
  <PictureDetails>
    <PictureURL>http://pics.ebay.com/aw/pics/dot_clear.gif</PictureURL>
    <PictureURL>fds</PictureURL>
    <PictureURL>fds</PictureURL>
  </PictureDetails>
</Item>

Which matches the format described in the ReviseItem API docs . 符合ReviseItem API文档中描述的格式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM