Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/google-sheets/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google sheets 如何在LUA中使用api密钥发出GET请求_Google Sheets_Lua_Google Sheets Api - Fatal编程技术网

Google sheets 如何在LUA中使用api密钥发出GET请求

Google sheets 如何在LUA中使用api密钥发出GET请求,google-sheets,lua,google-sheets-api,Google Sheets,Lua,Google Sheets Api,我试图从GoogleSheetAPI获得一个请求,但我不知道如何在代码中传递API密钥 local http = require("socket.http") local body, code, headers, status = http.request("https://sheets.googleapis.com/v4/spreadsheets/1AQK1WHGsavVmhNugAipMsrweB3m25xp01vtzGA8BvwE/values/Global!A1:D5") print(c

我试图从GoogleSheetAPI获得一个请求,但我不知道如何在代码中传递API密钥

local http = require("socket.http")
local body, code, headers, status = http.request("https://sheets.googleapis.com/v4/spreadsheets/1AQK1WHGsavVmhNugAipMsrweB3m25xp01vtzGA8BvwE/values/Global!A1:D5")
print(code, status, body)

现在我收到错误403,将其添加到URL末尾作为查询参数,如下所示:

 http.request("https://sheets.googleapis.com/v4/spreadsheets/[spreadsheet-id]/values/Global!A1:D5?key=[YOUR_API_KEY]") 
下一次,您可以在“尝试此API”窗口中单击展开图标,然后从该窗口发出请求,从而检查Sheets API[1]是如何发出请求的


[1]

我认为您需要在名为key的字段中使用http Post和api密钥: