Package com.bytedesk.social.instagram
Class InstagramPrivateRepliesService
java.lang.Object
com.bytedesk.social.instagram.InstagramPrivateRepliesService
Private Replies
私密回复
https://developers.facebook.com/docs/messenger-platform/instagram/features/private-replies
功能说明:
1. 允许Instagram专业账户向评论者发送私密消息
2. 支持帖子、广告帖子、快拍、直播故事的评论回复
3. 评论创建后7天内可发送私密回复(直播除外)
4. 直播评论只能在直播期间发送私密回复
5. 每个评论只能发送一条私密回复
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final long
private static final String
private final InstagramConfig
private final com.fasterxml.jackson.databind.ObjectMapper
private final org.springframework.web.client.RestTemplate
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate String
构建API URLvoid
clearSentRepliesCache
(String commentId) 清除已发送回复的缓存getCommentInfo
(String commentId) 获取评论信息int
获取已发送回复的评论数量handleCommentWebhook
(InstagramPrivateRepliesService.CommentData commentData, String autoReplyMessage) 处理评论webhook事件boolean
isSupportedForPrivateReply
(String mediaType) 检查媒体类型是否支持私密回复boolean
isValidReplyTime
(long commentCreatedTime, boolean isLiveComment) 验证回复时间是否有效private InstagramMessageResponse
parseErrorResponse
(String responseBody) 解析错误响应sendPrivateReply
(String commentId, String message) 发送私密回复private InstagramMessageResponse
sendPrivateReplyRequest
(String url, Map<String, Object> requestBody) 发送私密回复请求sendPrivateReplyWithValidation
(String commentId, String message, long commentCreatedTime, boolean isLiveComment) 发送私密回复(带时间验证)
-
Field Details
-
instagramConfig
-
restTemplate
private final org.springframework.web.client.RestTemplate restTemplate -
objectMapper
private final com.fasterxml.jackson.databind.ObjectMapper objectMapper -
INSTAGRAM_API_BASE_URL
- See Also:
-
COMMENT_REPLY_WINDOW_DAYS
private static final long COMMENT_REPLY_WINDOW_DAYS- See Also:
-
sentReplies
-
-
Constructor Details
-
InstagramPrivateRepliesService
public InstagramPrivateRepliesService()
-
-
Method Details
-
sendPrivateReply
发送私密回复- Parameters:
commentId
- 评论IDmessage
- 回复消息内容- Returns:
- 发送结果
-
sendPrivateReplyWithValidation
public InstagramMessageResponse sendPrivateReplyWithValidation(String commentId, String message, long commentCreatedTime, boolean isLiveComment) 发送私密回复(带时间验证)- Parameters:
commentId
- 评论IDmessage
- 回复消息内容commentCreatedTime
- 评论创建时间戳(秒)isLiveComment
- 是否为直播评论- Returns:
- 发送结果
-
handleCommentWebhook
public InstagramMessageResponse handleCommentWebhook(InstagramPrivateRepliesService.CommentData commentData, String autoReplyMessage) 处理评论webhook事件- Parameters:
commentData
- 评论数据autoReplyMessage
- 自动回复消息(可选)- Returns:
- 处理结果
-
isValidReplyTime
public boolean isValidReplyTime(long commentCreatedTime, boolean isLiveComment) 验证回复时间是否有效- Parameters:
commentCreatedTime
- 评论创建时间戳(秒)isLiveComment
- 是否为直播评论- Returns:
- 是否有效
-
isSupportedForPrivateReply
检查媒体类型是否支持私密回复- Parameters:
mediaType
- 媒体类型- Returns:
- 是否支持
-
getCommentInfo
获取评论信息- Parameters:
commentId
- 评论ID- Returns:
- 评论信息
-
clearSentRepliesCache
清除已发送回复的缓存- Parameters:
commentId
- 评论ID(可选,为null时清除所有缓存)
-
getSentRepliesCount
public int getSentRepliesCount()获取已发送回复的评论数量- Returns:
- 已发送回复的评论数量
-
buildApiUrl
构建API URL -
sendPrivateReplyRequest
private InstagramMessageResponse sendPrivateReplyRequest(String url, Map<String, Object> requestBody) 发送私密回复请求 -
parseErrorResponse
解析错误响应
-