首页 > 解决方案 > Facebook 从 image_hash 获取 AdImage url

问题描述

我的代码(python-business-sdk):

account = AdAccount(ad_account_id)
img = account.get_ad_images(params={'hashes': ['6b709f0275d0bdf18fb78ef08492ee79'})[0]
print(img['url'])  # doesnt work
primt(img[AdImage.Field.url])  # doesnt work

我做了请求,但在我的imgvar(AdImage obj)中只得到了 id 和 hash:

'{..., _json': {'hash': '6b709f0275d0bdf18fb78ef08492ee79', 'id': '36246837:6b709f0275d0bdf18fb78ef08492ee79'}}}

但我需要图像的 url,这里是带有字段的文档(url在那里),但我没有收到这些或不知道如何获取..
https://developers.facebook.com/docs/marketing-api/参考/广告图像#examples_read

标签: pythonapifacebookfacebook-graph-apifacebook-python-business-sdk

解决方案


只需将 fields 参数添加到 get_ad_images


推荐阅读