Class InstagramProductTemplateService

java.lang.Object
com.bytedesk.social.instagram.InstagramProductTemplateService

@Service public class InstagramProductTemplateService extends Object
用于 Instagram 消息的商品模板 产品模板 https://developers.facebook.com/docs/messenger-platform/instagram/features/product-template
  • Field Details

    • instagramConfig

      private final InstagramConfig instagramConfig
    • restTemplate

      private final org.springframework.web.client.RestTemplate restTemplate
    • objectMapper

      private final com.fasterxml.jackson.databind.ObjectMapper objectMapper
    • INSTAGRAM_API_BASE_URL

      private static final String INSTAGRAM_API_BASE_URL
      See Also:
  • Constructor Details

    • InstagramProductTemplateService

      public InstagramProductTemplateService()
  • Method Details

    • sendSingleProduct

      public InstagramMessageResponse sendSingleProduct(String recipientId, String productId)
      发送单个商品消息
      Parameters:
      recipientId - Instagram用户ID (IGSID)
      productId - 商品编号 (从Facebook目录获取)
      Returns:
      消息发送结果
    • sendProductCarousel

      public InstagramMessageResponse sendProductCarousel(String recipientId, List<String> productIds)
      发送商品轮播消息 (多个商品)
      Parameters:
      recipientId - Instagram用户ID (IGSID)
      productIds - 商品编号列表 (最多10个商品)
      Returns:
      消息发送结果
    • sendNotificationSubscriptionRequest

      public InstagramMessageResponse sendNotificationSubscriptionRequest(String recipientId, String imageUrl, String title, String payload, String frequency, String ctaText)
      发送订阅定期营销消息的请求
      Parameters:
      recipientId - Instagram用户ID (IGSID)
      imageUrl - 要在模板中显示的图像的网址
      title - 显示在模板中的标题 (最多65个字符)
      payload - 此定期通知订阅请求中的定期通知类型
      frequency - 定期通知订阅请求的消息频率 (DAILY, WEEKLY, MONTHLY)
      ctaText - 出现在行动号召按钮上的文本
      Returns:
      消息发送结果
    • sendDefaultNotificationSubscription

      public InstagramMessageResponse sendDefaultNotificationSubscription(String recipientId, String imageUrl, String title, String payload)
      发送默认订阅请求 (使用默认值)
      Parameters:
      recipientId - Instagram用户ID (IGSID)
      imageUrl - 要在模板中显示的图像的网址
      title - 显示在模板中的标题
      payload - 此定期通知订阅请求中的定期通知类型
      Returns:
      消息发送结果
    • sendDailyNotificationSubscription

      public InstagramMessageResponse sendDailyNotificationSubscription(String recipientId, String imageUrl, String title, String payload)
      发送每日订阅请求
      Parameters:
      recipientId - Instagram用户ID (IGSID)
      imageUrl - 要在模板中显示的图像的网址
      title - 显示在模板中的标题
      payload - 此定期通知订阅请求中的定期通知类型
      Returns:
      消息发送结果
    • sendWeeklyNotificationSubscription

      public InstagramMessageResponse sendWeeklyNotificationSubscription(String recipientId, String imageUrl, String title, String payload)
      发送每周订阅请求
      Parameters:
      recipientId - Instagram用户ID (IGSID)
      imageUrl - 要在模板中显示的图像的网址
      title - 显示在模板中的标题
      payload - 此定期通知订阅请求中的定期通知类型
      Returns:
      消息发送结果
    • sendMonthlyNotificationSubscription

      public InstagramMessageResponse sendMonthlyNotificationSubscription(String recipientId, String imageUrl, String title, String payload)
      发送每月订阅请求
      Parameters:
      recipientId - Instagram用户ID (IGSID)
      imageUrl - 要在模板中显示的图像的网址
      title - 显示在模板中的标题
      payload - 此定期通知订阅请求中的定期通知类型
      Returns:
      消息发送结果
    • isValidProductRequest

      public boolean isValidProductRequest(String recipientId, String productId)
      验证商品消息请求参数
    • isValidProductCarouselRequest

      public boolean isValidProductCarouselRequest(String recipientId, List<String> productIds)
      验证商品轮播消息请求参数
    • isValidNotificationSubscriptionRequest

      public boolean isValidNotificationSubscriptionRequest(String recipientId, String imageUrl, String title, String payload, String frequency, String ctaText)
      验证订阅请求参数
    • isValidNotificationFrequency

      public boolean isValidNotificationFrequency(String frequency)
      验证通知频率
    • isValidNotificationCtaText

      public boolean isValidNotificationCtaText(String ctaText)
      验证通知CTA文本
    • isValidUrl

      public boolean isValidUrl(String url)
      验证URL格式
    • buildApiUrl

      private String buildApiUrl()
      构建API URL
    • sendProductMessage

      private InstagramMessageResponse sendProductMessage(String url, Map<String,Object> requestBody)
      发送商品消息到Instagram API