Calling Back Data on Twitter
Function
Messages are pushed to Twitter when creating the Twitter channel. This interface is called back on Twitter for authentication.
Usage Description
Interface Authentication
/**
* Logic of channel authentication
*
* @param request Request
* @param response Response
*/
@Override
public void confirm(HttpServletRequest request, HttpServletResponse response) {
JSONObject returnObj = new JSONObject();
String requestUrl = UsUriUtils.getRequestURI(request);
String channelId = requestUrl.substring(requestUrl.lastIndexOf("/") + 1);
AiccLog.intf("start deal with twitter confirm url,channelId:{}", channelId);
if (CommonUtil.isEmpty(channelId)) {
log.error("The channelId is null when check confirm url");
return;
}
String crcToken = request.getParameter("crc_token");
ChannelConfig channelConfig = adapterCommonService.getChannelConfig(channelId);
String consumerSecret = twitterRedisService.getConsumerSecretAndDelete(channelId, channelConfig.getTenantId());
if (StringUtils.isEmpty(consumerSecret)) {
consumerSecret = getConsumerSecretFromChat(channelId);
}
if (StringUtils.isEmpty(consumerSecret)) {
log.error("channel id : {} consumer parameter lost!", channelId);
}
try {
String responseCode = BaseUtil.hMacSha256(crcToken, consumerSecret);
returnObj.put("response_token", "sha256=" + responseCode);
} catch (NoSuchAlgorithmException | InvalidKeyException e) {
log.error("hmac sha256 error,channelId:{},tenantId:{}", channelId,channelConfig.getTenantId());
}
AiccLog.intf("end deal with twitter confirm url,channelId:{}", channelId);
}
Interface Prototype
|
Method |
GET |
|
|---|---|---|
|
URL |
https://{IP address}:{Port number}/social/on/twitter/{channelId} |
{IP address}:{Port number} indicates the IP address and port number of the NSLB exposed externally. {channelId} indicates the channel ID. |
Request Parameters
|
Parameter |
Mandatory or Not |
Type |
Default Value |
Description |
|---|---|---|---|---|
|
Content-Type |
Yes |
String |
None |
The value is fixed at application/x-www-form-urlencoded. |
|
Parameter |
Mandatory or Not |
Type |
Default Value |
Description |
|---|---|---|---|---|
|
crc_token |
Yes |
String |
None |
Used to generate an MO interface authentication token. |
Response Parameters
|
Parameter |
Mandatory or Not |
Type |
Default Value |
Description |
|---|---|---|---|---|
|
response_token |
Yes |
JSON object |
None |
Used to generate an MO interface authentication token. |
Example
- Request
GET Content-Type: application/json;charset=UTF-8 https://ip/social/on/twitter/{channelId} x-www-form-urlencoded: key crc_token:xxxxxxxxxxxxxxxxxx - Response
HTTP/1.1 200 OK Content-Type: application/json;charset=UTF-8 { "response_token": "sha256=xxxxxxxxxx" }
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot