【问题标题】:Curl --user and -d equivalent in Javacurl --user 和 -d 在 Java 中的等价物
【发布时间】:2011-07-12 11:02:59
【问题描述】:

我想在我们的数据库中添加一些条目,它需要一些身份验证,我想使用 Java 而不是 Curl 来执行此操作。 API 只允许我执行这组命令来访问数据库。

curl --user user@someemail.com:password https://somewebsite.com/api/

添加新条目 curl -d "title=Title&address=address" https://somewebsite.com/api/new

删除条目 curl -X 删除 https://somewebsite.com/api/product/productid

Java 中是否有可以执行这种操作的库?

【问题讨论】:

    标签: java curl


    【解决方案1】:

    在java中使用HttpClient来实现同样的事情。

    http://hc.apache.org/httpclient-3.x/

    【讨论】:

      【解决方案2】:

      Apache HTTP Components 是第一个想到的,而且可能是最粗的。

      你可以搜索“Java REST API”,你会得到很多选择。

      https://stackoverflow.com/questions/1710199/which-is-the-best-java-rest-api-restlet-or-jersey 是另一个解决它的 SO 问题。

      【讨论】:

      • 嗨,你能在这个线程上帮助我吗bit.ly/nLZRRk。我遇到了身份验证问题,我一直被拒绝访问,但是当我尝试使用 cURL 时没问题。
      猜你喜欢
      • 2014-04-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-10-26
      • 2015-04-18
      • 2020-09-14
      • 1970-01-01
      相关资源
      最近更新 更多