更新时间:2025-11-13 GMT+08:00
twitter回调接口
接口功能
创建Twitter渠道时,推送消息给Twitter,Twitter回调本接口认证。
使用说明
接口鉴权
/**
* 渠道认证逻辑
*
* @param request 请求
* @param 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);
}
接口原型
|
请求方法 |
GET |
|
|---|---|---|
|
请求URL |
https://ip:port/social/on/twitter/{channelId} |
其中,ip:port为对外暴露的nslb的ip和port, channelId为渠道id |
请求参数
|
参数名称 |
选取原则 |
参数类型 |
默认值 |
说明 |
|---|---|---|---|---|
|
Content-Type |
必选 |
String |
无 |
固定填 application/x-www-form-urlencoded。 |
|
参数名称 |
选取原则 |
参数类型 |
默认值 |
说明 |
|---|---|---|---|---|
|
crc_token |
必选 |
String |
无 |
用于生成上行接口认证token。 |
响应参数
|
参数名称 |
选取原则 |
参数类型 |
默认值 |
说明 |
|---|---|---|---|---|
|
response_token |
必选 |
JSONObject |
无 |
用于生成上行接口认证token。 |
接口示例
- 请求示例
GET Content-Type: application/json;charset=UTF-8 https://ip/social/on/twitter/{channelId} x-www-form-urlencoded: key crc_token:xxxxxxxxxxxxxxxxxx - 响应示例
HTTP/1.1 200 OK Content-Type: application/json;charset=UTF-8 { "response_token": "sha256=xxxxxxxxxx" }
父主题: twitter渠道