【问题标题】:Can't able to integrate google calendar with ESP32...?无法将谷歌日历与 ESP32 集成...?
【发布时间】:2021-11-26 05:03:34
【问题描述】:

嗨,我正在尝试通过 esp32 获取日历事件,并且我正在使用带有 Lua(5.1) 的 NodeMCU 固件(Nodemcu:https://nodemcu.readthedocs.io/en/dev-esp32/modules/http/)我所做的一切都正确我为此编写了谷歌脚本并进行了测试chrome 和 postman 在这两种情况下 url 都可以正常工作,但是当尝试使用 esp32 时它不是......我无法自己调试,请帮我调试问题。

这是我一直在尝试的代码

headers = {["Content-Type"] = "application/json", ["Host"]="script.google.com",["Accept"]= "application/json, text/plain, /" ,}
connection = http.createConnection("https://script.google.com/macros/s/AKfycbybO_1kyXTxTOAJ8d4X0niOs-7y58TIfBhD92ThMuh8GJ/exec", http.GET, { headers=headers } )
connection:on("data", function(status,data)
  print("data =", status,data)
end)
connection:request()

我得到的错误是

<HEAD>
<TITLE>Moved Temporarily</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000">
<H1>Moved Temporarily</H1>
The document has moved <A HREF="https://script.googleusercontent.com/macros/echo?user_content_key=S3EjAkUDuxNdm-9dm2FVF3DWmazC_Qh0BGbIh1FAM_v_VkANvqPIszl-v-NCgqVk-jzU4NDO6FSjYkUTckVub_o2vxQNHFTUm5_BxDlH2jW0nuo2oDemN9CCS2h10ox_1xSncGQajx

data =  404 <!DOCTYPE html><html lang="en"><head><meta name="description" content="Web word processing, spreadsheets and presentations"><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0"><link rel="shortcut icon" href="//docs.google.com/favicon.ico"><title>Page not found</title><meta name="referrer" content="origin"><link href="//fonts.googleapis.com

data =  404 /css?family=Product+Sans" rel="stylesheet" type="text/css" nonce="BbT+xY6IwnjihR7Y0w7wAw"><style nonce="BbT+xY6IwnjihR7Y0w7wAw">/* Copyright 2021 Google Inc. All Rights Reserved. */
.goog-inline-block{position:relative;display:-moz-inline-box;display:inline-block}* html .goog-inline-block{display:inline}*:first-child+html .goog-inline-block{display:inline}#drive-logo{margin:

data =  404 18px 0;position:absolute;white-space:nowrap}.docs-drivelogo-img{background-image:url('//ssl.gstatic.com/images/branding/googlelogo/1x/googlelogo_color_116x41dp.png');background-size:116px 41px;display:inline-block;height:41px;vertical-align:bottom;width:116px}.docs-drivelogo-text{color:#000;display:inline-block;opacity:0.54;text-decoration:none;font-family:'Product Sans',Arial,Helvetica,sans-serif;font-size:32px;text-rendering:optimizeLegibility;position:relative;top:-6px;left:-7px;-webkit-font-smoothing:an

data =  404 tialiased;-moz-osx-font-smoothing:grayscale}@media (-webkit-min-device-pixel-ratio:1.5),(min-resolution:144dpi){.docs-drivelogo-img{background-image:url('//ssl.gstatic.com/images/branding/googlelogo/2x/googlelogo_color_116x41dp.png')}}</style><style type="text/css" nonce="BbT+xY6IwnjihR7Y0w7wAw">body {background-color: #fff; font-family: Arial,sans-serif; font-size: 13px; margin: 0; padding: 0;}a, a:link, a:visited {color: #112ABB;}</style><style type="text/css" nonce="BbT+xY6IwnjihR7Y0w7wAw">.errorMessage 

data =  404 {font-size: 12pt; font-weight: bold; line-height: 150%;}</style></head><body><div id="outerContainer"><div id="innerContainer"><div style="position: absolute; top: -80px;"><div id="drive-logo"><a href="/"><span class="docs-drivelogo-img" title="Google logo"></span><span class="docs-drivelogo-text">&nbsp;Drive</span></a></div></div><div align="center"><p class="errorMessage" 

data =  404 style="padding-top: 50px">Sorry, unable to open the file at present.</p><p> Please check the address and try again.</p><div style="background: #F0F6FF; border: 1px solid black; margin-top: 35px; padding: 10px 125px; width: 300px;"><p><strong>Get stuff done with Google Drive</strong></p><p>Apps in Google Drive make it easy to create, store and share online documents, spreadsheets, presentations and more.</p><p>Learn more at <a href="https://drive.google.com/start/apps">drive.google.com/start/apps</a>.</p></d

data =  404 iv></div></div></div></body><style nonce="BbT+xY6IwnjihR7Y0w7wAw">html {height: 100%; overflow: auto;}body {height: 100%; overflow: auto;}#outerContainer {margin: auto; max-width: 750px;}#innerContainer {margin-bottom: 20px; margin-left: 40px; margin-right: 40px; margin-top: 80px; position: relative;}</style></html>

我尝试了不同的标题但没有用,我尝试将数据上传到谷歌电子表格。相同的问题 url 适用于浏览器、Postman 和 esp32,它正在将数据上传到电子表格,但错误相同 (404)。我不明白为什么....

【问题讨论】:

  • 您认为“暂时搬家”可能意味着什么?还是“文档已移动”?
  • 嗨@romkey 我不知道这个..
  • 你怎么知道的?以“g”开头,以“e”结尾。
  • 另外你真的应该检查状态变量。
  • 对不起@romkey 我是初学者,不明白你在说什么,我需要日历返回的事件(来自谷歌脚本 url)

标签: google-apps-script https esp32 nodemcu


【解决方案1】:

您好,我找到了解决方案,首先问题在于 ESP32 http 请求,http 缓冲区大小较小,这就是为什么在重定向后,身份验证令牌没有完全接收(默认为 512 字节不足)所以它不能发出该请求(无法将令牌重定向到谷歌)给出 404 错误。增加缓冲区后它起作用了。在下面的代码中将缓冲区大小更新为 2048

connection=http.createConnection("https://script.google.com/macros/s/AKfycbyg3q6yhMQGWmPPH2e95/exec",  http.GET,{bufsz=2048} )
connection:on("data", function(status,data)
  print("data returned =", status,data)
end)
connection:on("complete", function(status)
  print("Request completed with status code =", status)
end)
connection:request()

如果有人愿意,我可以分享详细信息...

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-05-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-02-18
    • 2011-06-10
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多