如何通过eventbrite API将事件包含在事件中

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了如何通过eventbrite API将事件包含在事件中相关的知识,希望对你有一定的参考价值。

我试图通过eventbrite API发布和发布事件,但是这样做时我无法将媒体上传到事件中。我设法获得上传令牌,但不明白下一步该做什么。

def upload_file(filename):
    data = requests.get("https://www.eventbriteapi.com/v3/media/upload/?type=image-event-logo-preserve-quality&token=__token_here__").json()
    post_args = data['upload_data']
    response = requests.post(data['upload_url'],
        data = post_args,
        files = {
            data['file_parameter_name']: open(filename)   ######error in this line###
        }
    )
    return response, data['upload_token']

ta, tokn = upload_file("C:\Users\Nitish\Desktop\ERCESS_WORKSPACE\im.jpg")

Traceback (most recent call last):
  File "test.py", line 78, in <module>
    ta, tokn = upload_file(r'im.jpg')
  File "test.py", line 55, in upload_file
    data['file_parameter_name']: open(filename)
  File "C:UsersNitishAppDataLocalProgramsPythonPython37libsite-packages
equestsapi.py", line 116, in post
    return request('post', url, data=data, json=json, **kwargs)
  File "C:UsersNitishAppDataLocalProgramsPythonPython37libsite-packages
equestsapi.py", line 60, in request
    return session.request(method=method, url=url, **kwargs)
  File "C:UsersNitishAppDataLocalProgramsPythonPython37libsite-packages
equestssessions.py", line 519, in request
    prep = self.prepare_request(req)
  File "C:UsersNitishAppDataLocalProgramsPythonPython37libsite-packages
equestssessions.py", line 462, in prepare_request
    hooks=merge_hooks(request.hooks, self.hooks),
  File "C:UsersNitishAppDataLocalProgramsPythonPython37libsite-packages
equestsmodels.py", line 316, in prepare
    self.prepare_body(data, files, json)
  File "C:UsersNitishAppDataLocalProgramsPythonPython37libsite-packages
equestsmodels.py", line 504, in prepare_body
    (body, content_type) = self._encode_files(files, data)
  File "C:UsersNitishAppDataLocalProgramsPythonPython37libsite-packages
equestsmodels.py", line 159, in _encode_files
    fdata = fp.read()
  File "C:UsersNitishAppDataLocalProgramsPythonPython37libencodingscp1252.py", line 23, in decode
    return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x81 in position 248: character maps to <undefined>
答案

二进制读取将非常有用,因为图像视频以二进制读取模式存储。媒体文件以二进制模式上载。

以上是关于如何通过eventbrite API将事件包含在事件中的主要内容,如果未能解决你的问题,请参考以下文章

在 Ruby 中解析来自 Eventbrite API 的 JSON 响应

访问组织者个人资料图片 Eventbrite API

Eventbrite 重定向 URI iOS OAuthSwift

OS X:如何将鼠标拖动事件通过视图传递给超级视图

如何通过 Graph API 创建一个 Facebook 事件以具有特定时间和时区,该时间和时区不会因个人用户而改变?

当所包含的react元素具有箭头函数事件处理程序时,如何使用.contains(nodeOrNodes)API?