我正在尝试将图像上传到imgur.com(apidocs.imgur.com)。但是由于某些原因,请求成功完成,并向我提供了图像链接,但该图像未显示在imgur.com中
def upload_imgur(image_name):
imgur_upload_url = "https://api.imgur.com/3/image"
# payload = {'image': 'R0lGODlhAQABAIAAAAAAAP'}
files = {}
payload = {'image': open(image_name, 'rb')}
headers = {
'Authorization': 'Client-ID {} Bearer {}'.format(client_id, access_token)
}
response = requests.request('POST',imgur_upload_url, headers=headers, files=payload)
logger.info(headers)
try:
link = response.json()
logger.info('Data link {}'.format(link))
return True
except KeyError:
link = "Failed"
return False
响应:
{'data': {'id': 'b1hOr9v', 'title': None, 'description': None, 'datetime': 1555000696, 'type': 'image/jpeg', 'animated': False, 'width': 225, 'height': 225, 'size': 2844, 'views': 0, 'bandwidth': 0, 'vote': None, 'favorite': False, 'nsfw': None, 'section': None, 'account_url': None, 'account_id': 0, 'is_ad': False, 'in_most_viral': False, 'has_sound': False, 'tags': [], 'ad_type': 0, 'ad_url': '', 'edited': '0', 'in_gallery': False, 'deletehash': 'ulCxGeNZk8r34s3', 'name': '', 'link': 'https://i.imgur.com/b1hOr9v.jpg'}, 'success': True, 'status': 200}
但是我的帐户中没有图像。请帮忙!