我正在尝试路由文本节点以在 Google App 脚本中创建文本。我基本上让代码通过循环运行,从 Figma 获取文本并将其放在谷歌幻灯片中。我不确定为什么 API 没有运行。这是我的代码。
Figma API 链接:https ://www.figma.com/developers/api
function fuctionn2() {
{
var accessToken = "25582-30567a98-fd4a-4a86-a9a9-7a7b57f77d17"; // Please set your access token.
var fileKey = "AKNad61GojhTj0TlTnn9AC"; // Please set the file key.
var baseUrl = "https://api.figma.com/v1";
var params = {
method: "get",
headers: {"X-Figma-Token": accessToken},
muteHttpExceptions: true,
};
var fileInfo = JSON.parse(UrlFetchApp.fetch(baseUrl + "/files/" + fileKey, params))
var children = args = [
"text = vector",
"text=characters",
"outputDir=./lib/build"
]
}
var response = request.postData.getDataAsString(.);
// save that JSON to a file
DriveApp.createFile('post.json', postJSON);
*var response = UrlFetchApp.fetch(baseURL {'text': true});*
Logger.log(response);
if (RunText.err) {
var s = SlidesApp.create("sampleSlide");
var shape = s.insertShape(SlidesApp.ShapeType.TEXT_BOX, 100, 200, 300, 60);
var textRange = shape.getText();
var selectionType = selection.getSelectionType();
var keys = Object.keys(children.t);
textRange.forEach(function(c, i) {
textRange.setText(children.t[c]);
textRange.insertText(chlidren.length);
if (i != textRange.length - 1)s.insertSlide(i+1)
});
} else {
throw new Error(children);
}
}
我尝试通过我的函数运行这个 JSON 文件,我的文件能够对 JSON Fille 做出反应,但现在我需要在我的脚本中获取这个 JSON 文件。
t 仍被视为未定义