Google REST API

编程入门 行业动态 更新时间:2024-10-13 16:16:15
本文介绍了Google REST API - RFC 2822 格式和 base64url 编码字符串中的消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

我尝试使用 - 试试看 的 Google REST API - Users.messages: send .

有一个必需的参数 - raw -

<块引用>

采用 RFC 2822 格式和 base64url 编码字符串的整个电子邮件消息.在messages.get 和drafts.get 响应中返回时提供了 format=RAW 参数.

我检查了 RFC 2822 格式,似乎它应该显示为 sample here ,然后我用这个编码器将 base64URL 编码并将其粘贴到 raw 字段/v1/reference/users/messages/send#try-it" rel="noreferrer">尝试 我得到 - 字节字符串的无效值:http://ostermiller/calc/encode.html .

你能给我提供一个正确的 RFC 2822 格式 及其对应的 base64URL,它可以在上面的 试试 ?

解决方案

示例邮件可能如下所示:

发件人:sender@gmail至:receiver@gmail主题:主题文本消息文本在这里

在您的浏览器中打开开发者工具并对其进行 Base64 编码并将所有 + 替换为 -,将所有 / 替换为 _,并删除尾随的 = 以使其 URL 安全:

btoa("发件人:sender@gmail\r\n" +"收件人:receiver@gmail\r\n" +"主题:主题文本\r\n\r\n" +消息文本在这里").replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '');

这将为您提供以下数据:

RnJvbTogc2VuZGVyQGdtYWlsLmNvbQ0KVG86IHJlY2VpdmVyQGdtYWlsLmNvbQ0KU3ViamVjdDogU3ViamVjdCBUZXh0DQoNClRoZHlWlXZIHpZYpdZXIHJlY2VpdmVyQGdtYWlsLmNvbQ0KU3ViamVjdDogU3ViamVjdXI

使用上述字符串作为 raw 参数尝试"rel="noreferrer">API Explorer 发送邮件.

I try the use the - try it of Google REST API - Users.messages: send .

There is there a required parameter - raw -

The entire email message in an RFC 2822 formatted and base64url encoded string. Returned in messages.get and drafts.get responses when the format=RAW parameter is supplied.

I checked about RFC 2822 format and seems it should displayed as the sample here , then I encoded it the base64URL with this encoder and paste it the raw field of the try it and I get - Invalid value for ByteString: http://ostermiller/calc/encode.html .

Can you provide me a correct RFC 2822 format and its corresponding base64URL which it would work in the above try it ?

解决方案

An example mail could look like this:

From: sender@gmail
To: receiver@gmail
Subject: Subject Text

The message text goes here

Open up the Developer Tools in your browser and Base64 encode it and replace all + with -, replace all / with _, and remove the trailing = to make it URL-safe:

btoa(
  "From: sender@gmail\r\n" +
  "To: receiver@gmail\r\n" +
  "Subject: Subject Text\r\n\r\n" +

  "The message text goes here"
).replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '');

This will give you the following data:

RnJvbTogc2VuZGVyQGdtYWlsLmNvbQ0KVG86IHJlY2VpdmVyQGdtYWlsLmNvbQ0KU3ViamVjdDogU3ViamVjdCBUZXh0DQoNClRoZSBtZXNzYWdlIHRleHQgZ29lcyBoZXJl

Use this string above as your raw-parameter in the API Explorer to send the mail.

这篇关于Google REST API - RFC 2822 格式和 base64url 编码字符串中的消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

更多推荐

[db:关键词]

本文发布于:2023-04-18 16:27:07,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/942168.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Google   REST   API

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!