尝试将轮播帖子上传到 Instagram。
使用这个官方指南。它由 3 个步骤组成,但我似乎无法完成第二步。
def carouselcontainer(item_ids,caption):
#Post the Image
post_url = 'https://graph.facebook.com/v15.0/{}/media'.format(account_id)
payload = {
'caption' : caption,
'media_type' : 'CAROUSEL',
'children': item_ids,
'access_token' : access_token
}
r = requests.post(post_url, data=payload)
print(r.text)
result = json.loads(r.text)
if 'id' in result:
return result['id']
print(carouselcontainer(['17983349911631232', '179288683854321234'],'test caption'))
这是我使用的代码。
{"error":{"message":"(#100) Unsupported post type. The post has too little or too many attachments to qualify as a carousel","type":"OAuthException","code":100,"fbtrace_id":"AzcboMr7axTy9Aaqd8eo_K3"}}
该错误表明我的附件太少或太多,即使我发送了 2 个项目容器,这对于轮播容器来说应该足够了。
嗨,您的代码看起来很完美。只需要改变
r = requests. Post(post_url, data=payload)
到
r = requests.Post(post_url, json=payload)
因为您是作为数据传递的,所以它不是数组而是数组的单个元素,这就是为什么会出现该错误
需要帮助。 有同样的错误。
有人知道吗? 谢谢