Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/307.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Flickr API:使用python上传图像_Python_Oauth_Python Requests_Flickr - Fatal编程技术网

Flickr API:使用python上传图像

Flickr API:使用python上传图像,python,oauth,python-requests,flickr,Python,Oauth,Python Requests,Flickr,我在Flickr API上上传图像时遇到问题 我使用OAuthLib请求() Flickr文档: 我的代码: params = { 'format' : 'json', "nojsoncallback" : "1", 'api_key' : 'my_api_key', } with open('myfile.jpg', 'rb') as f: files = {'file': f} r = the_oauth_reques

我在Flickr API上上传图像时遇到问题

我使用OAuthLib请求()

Flickr文档:

我的代码:

params = {
    'format'         : 'json',
    "nojsoncallback" : "1",
    'api_key'        : 'my_api_key',
}

with open('myfile.jpg', 'rb') as f:
    files = {'file': f}

    r = the_oauth_requests_session.post('https://up.flickr.com/services/upload/', params=params, files=files)
    print r.content
但在内容中我可以找到这个错误:“没有指定照片”

上传照片的方式是什么

我已通过身份验证,其他api调用也能完美工作(如“flickr.photosets.create”)


提前谢谢你

我认为Flickr不允许你上传图像和视频以外的任何其他文件类型。 在代码中:

files = {'file': f}

您确定“文件”的类型正确吗?

解决方案非常简单:

files = {'photo': f}
而不是:

files = {'file': f}

为什么不使用类似这样的工具来处理所有繁重的工作呢?因为我需要Python 3支持:/