簡體   English   中英

HTTP Post獲得令牌響應?

[英]HTTP Post get token response?

我正在使用Sinusbot API以Java發出發布請求。

我最大程度地得到了200的反饋,這很好。

但是,它也假設在發出請求時返回一個令牌進行登錄,但是我不知道如何獲得它。

有任何想法嗎?

https://www.sinusbot.com/api/#api-General-login

在try catch語句中

 HttpPost request = new HttpPost("http://127.0.0.1:8087/api/v1/bot/login"); // StringEntity params =new StringEntity("{'username': 'xx','password': 'foobar', 'botId': 'fillme'}"); String payload = "{'username': 'test','password': 'atisbot', 'botId': '2ad5bffa-4374-4ef4-abae-77e793163577'}"; //atisbot 172b398f-f217-4bbc-8e14-9ea5f1463db7 StringEntity entity = new StringEntity(payload, ContentType.APPLICATION_FORM_URLENCODED); request.setEntity(entity); HttpResponse response = httpClient.execute(request); System.out.println(response.getStatusLine().getStatusCode()); 

響應是純文本,可能是令牌。

String token = EntityUtils.toString(response.getEntity())

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM