【问题标题】:Problems uploading to imgur using my key?使用我的密钥上传到 imgur 时出现问题?
【发布时间】:2013-02-16 07:18:06
【问题描述】:
var values = new NameValueCollection
{
    { "key", "key_edited_for_security" },
    { "image", Convert.ToBase64String(ms.ToArray()) }
};

byte[] response = w.UploadValues("https://api.imgur.com/2/upload.xml", values);

这工作得很好,关键来自几年前某人创建的另一篇 stackoverflow 帖子 (Uploading to imgur.com),我已经在 imgur here 注册了我的应用程序,但是当我使用我的客户端 ID 或客户端时秘密 ID 我收到错误 400(错误请求)。

【问题讨论】:

  • 永远不要在公共场所发布您的 API 密钥!键已编辑!
  • 这不是我的,它来自我链接的另一个问题,它是第一个出现在谷歌上的,所以它几乎不是私人的。
  • 也许他们需要时间将您添加到数据库

标签: c# imgur


【解决方案1】:

我确实测试了上面的代码,似乎工作正常

    static void Main(string[] args)
    {

        WebClient client = new WebClient();
        NameValueCollection values = new NameValueCollection();
        values["image"] = Convert.ToBase64String(File.ReadAllBytes(@"C:\test.jpg"));
        values["key"] = "the_key";
        byte[] responseBytes = client.UploadValues("https://api.imgur.com/2/upload.xml", values);
        string response = Encoding.Default.GetString(responseBytes);
        client.Dispose();
        /* Content of response 
        <?xml version="1.0" encoding="utf-8"?>
        <upload><image><name/><title/><caption/><hash>E63BcFm</hash><deletehash>zWO2xnca2co0VcB</deletehash><datetime>2013-02-15 23:15:45</datetime><type>image/jpeg</type><animated>false</animated><width>677</width><height>342</height><size>29513</size><views>0</views><bandwidth>0</bandwidth></image><links><original>http://i.imgur.com/E63BcFm.jpg</original><imgur_page>http://imgur.com/E63BcFm</imgur_page><delete_page>http://imgur.com/delete/zWO2xnca2co0VcB</delete_page><small_square>http://i.imgur.com/E63BcFms.jpg</small_square><large_thumbnail>http://i.imgur.com/E63BcFml.jpg</large_thumbnail></links></upload>
        */
    }

【讨论】:

  • 用哪个键?正如我所说,它可以与问题中的原始密钥一起使用,但使用我的则不行。
  • 在他们的网站上找到了匿名密钥,不过感谢您的帮助。
猜你喜欢
  • 2013-12-29
  • 1970-01-01
  • 2022-08-16
  • 2014-10-15
  • 2021-07-14
  • 1970-01-01
  • 2017-11-21
  • 2014-06-07
  • 1970-01-01
相关资源
最近更新 更多