【问题标题】:RingCentral Glip webhook not supporting unusual characters received via emailRingCentral Glip webhook 不支持通过电子邮件收到的异常字符
【发布时间】:2018-01-28 14:36:13
【问题描述】:

我正在尝试在 Linux 上使用他们的 webhook 进程从 php 向 RingCentral Glip 发送数据。

我实际上在做的是处理传入的邮件消息并将它们重新格式化为 Glip 消息格式,然后通过 Glip webhook 提交它们。
但我遇到了似乎是字符集兼容性问题。

我不完全确定 Glip 支持什么字符集,但我尝试将其格式化为 UTF-8,但当我提交它时,消息永远不会被发布。

如果我只使用纯 ASCII 字符,则消息发布没有任何问题。

有人知道 Glip 需要什么格式吗?
是否有任何现有的代码库可供人们使用 PHP 将文本转换为该格式?

【问题讨论】:

    标签: webhooks ringcentral glip ringcentral-webhooks


    【解决方案1】:

    我的答案是我不知道 GLIP 需要什么字符格式,但我现在知道它不会导致我的问题。事实证明,我有两个错误导致我的消息正文被删除,如果您发送消息以使用空正文进行闪烁,它会提交空消息,而不仅仅是显示设置的活动和标题信息(如您所料如果正文是空白的)它只是将其视为完全空白。

    【讨论】:

      【解决方案2】:

      UTF-8 无需任何特殊转换即可为我工作,如下所示。是否有可能电子邮件转换为 UTF-8 没有按预期工作?您能否发布一个不适合您的 UTF-8 示例以及您的期望?

      以下演示消息适用于我,并提供了 JSON 和屏幕截图。我已将♠♥♣♦ 添加到每个文本字段以进行验证。

      您可以在此处找到示例 Go 代码:

      代码:github.com/grokify/go-glip/...

      {
        "icon": "https://i.imgur.com/9yILi61.png",
        "title": "**Title of the post ♠♥♣♦**",
        "body": "Body of the post ♠♥♣♦",
        "attachments": [
          {
            "color": "#00ff2a",
            "pretext": "Attachment pretext appears before the attachment block ♠♥♣♦",
            "author_name": "Author Name ♠♥♣♦",
            "author_link": "https://example.com/author_link",
            "author_icon": "https://upload.wikimedia.org/wikipedia/commons/thumb/f/fd/000080_Navy_Blue_Square.svg/1200px-000080_Navy_Blue_Square.svg.png",
            "title": "Attachment Title ♠♥♣♦",
            "title_link": "https://example.com/title_link",
            "fields": [
              {
                "title": "Field 1 ♠♥♣♦",
                "value": "A short field ♠♥♣♦",
                "short": true
              },
              {
                "title": "Field 2",
                "value": "This is [a linked short field](https://example.com)",
                "short": true
              },
              {
                "title": "Field 3 ♠♥♣♦",
                "value": "A long, full-width field with *formatting* and [a link](https://example.com) \n\n ♠♥♣♦"
              }
            ],
            "text": "Attachment text ♠♥♣♦",
            "image_url": "https://media3.giphy.com/media/l4FssTixISsPStXRC/giphy.gif",
            "thumbnail_url": "https://funkybuddhabrewery.com/sites/default/files/WorldBeerCupGold.png",
            "footer": "Attachment footer and timestamp ♠♥♣♦",
            "footer_icon": "http://www.iconsdb.com/icons/preview/red/square-ios-app-xxl.png",
            "ts": 1517169226
          }
        ]
      }
      

      有关邮件格式的更多信息,请点击此处:

      http://ringcentral-api-docs.readthedocs.io/en/latest/glip_message_attachments/

      【讨论】:

      • 感谢您的测试。我看到你正在使用 Go,我正在使用 PHP。也就是说,您的帖子对我非常有帮助,因为我意识到它应该可以工作。实验表明,我的代码中有两个错误导致消息内容无效。似乎如果消息内容是空白的,glip 实际上不会显示您提供的任何其他信息,而只是发布一个完全空白的帖子。所以我的问题毕竟不是字符的编码,而是我的代码使消息空白,而 glip 接收空白消息并将所有内容都空白。感谢您的帮助!
      • 为了展示 UTF-8 的工作原理,这里的 JSON 主体比实际代码更重要。很高兴您解决了这个问题,并感谢您报告您的发现!
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-08-30
      • 2016-02-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多