Class MetaMaterialService

java.lang.Object
com.bytedesk.social.meta.MetaMaterialService

@Service public class MetaMaterialService extends Object
Meta平台素材服务 用于上传附件并获取attachment_id,用于媒体模板 参考文档: https://developers.facebook.com/docs/messenger-platform/send-messages/saving-assets https://developers.facebook.com/docs/messenger-platform/reference/attachment-upload-api/ 注意:附件编号将于90天后过期。附件编号过期后,您将需要重新上传素材,才能获取新附件编号。
  • Field Details

    • restTemplate

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

      private final com.fasterxml.jackson.databind.ObjectMapper objectMapper
  • Constructor Details

    • MetaMaterialService

      public MetaMaterialService()
  • Method Details

    • saveMaterialByUrl

      public String saveMaterialByUrl(String pageId, String accessToken, String type, String url)
      通过URL保存素材,返回attachment_id
      Parameters:
      pageId - 页面ID
      accessToken - 访问令牌
      type - 附件类型 (image, video, audio, file)
      url - 文件URL
      Returns:
      attachment_id,失败时返回null
    • saveMaterialByFile

      public String saveMaterialByFile(String pageId, String accessToken, String type, org.springframework.web.multipart.MultipartFile file)
      通过文件上传保存素材,返回attachment_id
      Parameters:
      pageId - 页面ID
      accessToken - 访问令牌
      type - 附件类型 (image, video, audio, file)
      file - 上传的文件
      Returns:
      attachment_id,失败时返回null
    • isValidAttachmentType

      public boolean isValidAttachmentType(String type)
      验证附件类型是否有效
      Parameters:
      type - 附件类型
      Returns:
      是否有效
    • getAttachmentTypeDescription

      public String getAttachmentTypeDescription(String type)
      获取附件类型描述
      Parameters:
      type - 附件类型
      Returns:
      类型描述