谷歌REST API - 在RFC 2822的消息格式和base64url EN codeD字符串 [英] Google REST API - message in an RFC 2822 formatted and base64url encoded string

查看:330
本文介绍了谷歌REST API - 在RFC 2822的消息格式和base64url EN codeD字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用 - 试试吧谷歌REST API的 - Users.messages:发送

有有没有所需的参数 - 原材料 -


  

在格式化的RFC 2822和EN base64url codeD字符串的整个电子邮件消息。返回在messages.get和drafts.get响应时
  格式=原始参数提供。


我查了一下RFC 2822的格式,似乎它应该显示为的这里样品,然后我带codeD它base64URL与此连接codeR并将其粘贴在的原材料字段= https://developers.google.com/gmail/api/v1/reference/users/messages/send#try-it相对=nofollow>尝试的,我得到 - 为字节字符串值无效:http://ostermiller.org/calc/en$c$c.html

您可以给我一个正确的 RFC 2822格式及其相应的 base64URL 其中,将在上述工作< A HREF =htt​​ps://developers.google.com/gmail/api/v1/reference/users/messages/send#try-it相对=nofollow>试试的?


解决方案

这是例如邮件将如下所示:

 的Content-Type:text / plain的;字符集=UTF-8
MIME-版本:1.0
内容传输编码:7位
于:receiver@gmail.com
来自:sender@gmail.com
主题:主题文本实际的消息文本放在这里

在浏览器的Base64 EN code将其打开开发者工具和全部替换+与 - 和所有/与_,使其安全网址

  BTOA(
内容类型:text / plain的;字符集= \\UTF-8 \\\\ n+
MIME-版本:1.0 \\ n+
内容传输编码:7位\\ n+
来:receiver@gmail.com \\ n+
来自:sender@gmail.com \\ n+
主题:主题文字\\ n \\ n+实际的消息文本放在这里
).replace(/ \\ + /克,' - ')取代(/ \\ //克,_);

这会给你以下数据:

<$p$p><$c$c>\"Q29udGVudC1UeXBlOiB0ZXh0L3BsYWluOyBjaGFyc2V0PSJVVEYtOCIKTUlNRS1WZXJzaW9uOiAxLjAKQ29udGVudC1UcmFuc2Zlci1FbmNvZGluZzogN2JpdAp0bzogcmVjZWl2ZXJAZ21haWwuY29tCmZyb206IHNlbmRlckBnbWFpbC5jb20Kc3ViamVjdDogaGV5CgpoZWhlaGU=\"

不要忘记改变的例子接收器和发送电子邮件!把中间值''-characters在上面的原始 - 参数在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.org/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 would be as follows:

Content-Type: text/plain; charset="UTF-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
to: receiver@gmail.com
from: sender@gmail.com
subject: Subject Text

The actual message text goes here

Open up the Developer Tools in your browser and Base64 encode it and replace all "+" with "-" and all "/" with "_" to make it URL-safe.

btoa(
"Content-Type: text/plain; charset=\"UTF-8\"\n" +
"MIME-Version: 1.0\n" +
"Content-Transfer-Encoding: 7bit\n" +
"to: receiver@gmail.com\n" +
"from: sender@gmail.com\n" +
"subject: Subject Text\n\n" +

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

This will give you the following data:

"Q29udGVudC1UeXBlOiB0ZXh0L3BsYWluOyBjaGFyc2V0PSJVVEYtOCIKTUlNRS1WZXJzaW9uOiAxLjAKQ29udGVudC1UcmFuc2Zlci1FbmNvZGluZzogN2JpdAp0bzogcmVjZWl2ZXJAZ21haWwuY29tCmZyb206IHNlbmRlckBnbWFpbC5jb20Kc3ViamVjdDogaGV5CgpoZWhlaGU="

Don't forget to change the example receiver and sender emails! Putting the value between the '"'-characters above in the "raw"-parameter in the API explorer will send the mail.

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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆