HTTPClient代码中的CURL命令

问题描述:

我正在计划使用文本上传网站http://textuploader.com/,但我似乎无法理解这一点。我可能没有看上去很难,但那不是重点。我真正想要的只是如何执行这些命令,或者只是如何使用“HTTPClient”来做这些事情。包含所有命令和信息的网站是here。此外,只是为了方便起见,我要离开最重要的对我来说,在这个帖子:HTTPClient代码中的CURL命令

POST: /posts 

This will allow you to post to your account. 

{ 
    "Title": "Sample Title", 
    "Content": "Post body goes here.", 
    "Type": "public" 
} 

Example: 

curl -X POST "http://api.textuploader.com/v1/posts" \ 
-H "Accept: application/json" \ 
-H "Content-Type: application/json" \ 
-H "X-TextUploader-API-Key: your-api-key-here" \ 
-v \ 
-d '{"title": "Sample Title", "content": "Post body goes here.", "type": "public"}' 

And this: 

GET: /posts/[shortcode] 

This method will return the complete body of the requested shortcode. 
+0

检查我的答案在这里http://*.com/questions/36475076/how-to-make-post-curl-request-in-java –

+0

啊,谢谢你,完美! – Dankrushen

Nicolas Filotto的上这里的答案是完美的:How to make post curl request in java

这是,如果你宁愿留在此页:

如果我是你,我会用DavidWebb一个轻量级的Java HTTP客户端调用JSON REST的服务,并继续执行下一个:

Webb webb = Webb.create(); 
JSONObject result = webb 
    .post("https://api.gupshup.io/appsdk/api/components/adduser") 
    .header("Content-Type", "application/x-www-form-urlencoded") 
    .header("apikey", "xxxx") 
    .body("name=abcd&[email protected]&id=abc") 
    .asJsonObject() 
    .getBody();