我打電話給Twilio客戶端打電話並提供To,From和url參數。我想將XSRF標記設置爲url的一部分,這樣當twilio調用url時,標記將被驗證,並且我的其餘api發送twiml表達式,以便twilio將調用其他電話號碼並連接兩個調用。有什麼辦法可以將XSRF標記設置爲標題的一部分。以下是我的代碼。發送帶請求url的標頭參數 - twilio
TwilioRestClient client = new TwilioRestClient(accountSid, authToken);
Account mainAccount = client.getAccount();
CallFactory callFactory = mainAccount.getCallFactory();
Map<String, String> callParams = new HashMap<String, String>();
callParams.put("To", "+1 xxx-xxx-xxxx");
callParams.put("From", "+1 xxx-xxx-xxxx");
callParams.put("X-XSRF-TOKEN", "token");
callParams.put("Url", "myurl/+1xxx-xxx-xxxx");
try {
Call call = callFactory.create(callParams);
} catch (TwilioRestException e) {
e.printStackTrace();
}
我的應用程序執行令牌認證,因此在訪問我的回調休息服務以獲取Twiml表達式時發出異常(錯誤403期望的CSRF令牌未找到。您的會話是否已過期?)。你能否建議我使其工作的最佳方法? – laks