2017-04-23 47 views
0

如何通過智威湯遜承載令牌頭郵政使用Java代碼的我不想接吻Java代碼來改變Smooch.io PostMessage的API通過智威湯遜在頭PARAM

我曾試圖與postMessageCall改變談話的api這正常工作

但我不想改變接吻代碼

ConversationApi conversationApi = new ConversationApi(); 

    Action action = new Action(); 
    action.setType(TypeEnum.REPLY); 

    action.setText("reply"); 


    ArrayList<Action> actionList = new ArrayList<Action>(); 
    actionList.add(action); 

    MessageItem item1 = new MessageItem(); 
    item1.setActions(actionList); 
    item1.setTitle("yes"); 

    ArrayList<MessageItem> messageItems = new ArrayList<>(); 
    messageItems.add(item1); 

    MessagePost messagePost = new MessagePost(); 
    messagePost.setText("amit thak gya hai "); 
    messagePost.setType(io.smooch.client.model.MessagePost.TypeEnum.TEXT); 
    messagePost.setRole("appMaker"); 
    messagePost.setItems(null); 
    messagePost.setActions(null); 

    ApiClient apiClient = new ApiClient(); 
    Map<String, String> setJWTToken = setJWTToken(apiClient); 
    // String userId = userId; 
    try { 
     // conversationApi.setApiClient(setJWTToken); 
     PostMessagesResponse postMessage = conversationApi.postMessage(userId, messagePost); 
     System.out.println("Response : " + postMessage); 
    } catch (ApiException exception) { 
     // TODO: prateek. Write exception handling code 
     System.out.println("Exception : " + exception); 
    } 
} 

private static Map<String, String> setJWTToken(ApiClient apiClient) { 
    Map<String, String> localVarHeaderParams = new HashMap<String, String>(); 

    final String bearer = "Bearer some token value"; 
    final String[] localVarAccepts = {bearer}; 
    final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); 
    if (localVarAccept != null) { 
     localVarHeaderParams.put("Accept", localVarAccept); 
    } 
    localVarHeaderParams.put("Authorization", bearer); 
    return localVarHeaderParams; 
} 

}

+0

請發表你可以嘗試代碼找出問題 –

+0

@ user7790438我已編輯疑問句 –

回答

1

早些時候,流量爲我的班級 - >便利着想rsationAPI - > apiClient 現在我已經通過設置頭PARAM在我 和Class流跳過了中間層是我的班級 - > apiClient