2016-04-21 60 views
1

我正在計劃使用文本上傳網站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://stackoverflow.com/questions/36475076/how-to-make-post-curl-request-in-java –

+0

啊,謝謝你,完美! – Dankrushen

回答

0

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();