开发者

How to upload images using an API Key that gives you permission to upload? [Python source code included]

开发者 https://www.devze.com 2022-12-16 12:40 出处:网络
The documentation of the API shows 开发者_如何学Csource code on how to accomplish this in Python:

The documentation of the API shows 开发者_如何学Csource code on how to accomplish this in Python:

#!/usr/bin/python

import pycurl

c = pycurl.Curl()
values = [
          ("key", "YOUR_API_KEY"),
          ("image", (c.FORM_FILE, "file.png"))]
# OR:     ("image", "http://example.com/example.jpg"))]

c.setopt(c.URL, "http://imgur.com/api/upload.xml")
c.setopt(c.HTTPPOST, values)

c.perform()
c.close()

I'd like a bit of guidance on how to do this in C#. For instance, I'm lost on what these "values" would be in C#, how would I even declare them?

I'm not familiar with cURL at all, so that might be holding me back from translating a bit.

Help me Obi-wan. You're my only hope. /click


You just need to perform an HTTP POST, e.g. this code with a "parameters" string of key=YOUR_API_KEY&image=http://example.com/example.jpg or the like.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号