我应该在此 Google Script GET 请求中使用 .getContentText() 吗?
Should I use .getContentText() in this Google Script GET request?
这两个似乎 return 并记录相同的内容。使用哪个有关系吗?第一个示例是 documentation.
上显示的内容
var rawCalendar1 = UrlFetchApp.fetch("https://example.com/blog/events.ics");
Logger.log(rawCalendar1.getContentText());
var rawCalendar2 = UrlFetchApp.fetch("https://example.com/blog/events.ics");
Logger.log(rawCalendar2);
Return UrlFetchApp.fetch() 的类型是 HttpResponse。在您的示例中,您可以在 rawCalendar1 上调用多个方法来检查返回值。
见https://developers.google.com/apps-script/reference/url-fetch/http-response
getContentText() 将 HttpResponse 的内容转换为类型 'string'。同样,Logger.log() 将括号之间的内容转换为 'string',这与在其上调用 getContentText() 基本相同。
这两个似乎 return 并记录相同的内容。使用哪个有关系吗?第一个示例是 documentation.
上显示的内容var rawCalendar1 = UrlFetchApp.fetch("https://example.com/blog/events.ics");
Logger.log(rawCalendar1.getContentText());
var rawCalendar2 = UrlFetchApp.fetch("https://example.com/blog/events.ics");
Logger.log(rawCalendar2);
Return UrlFetchApp.fetch() 的类型是 HttpResponse。在您的示例中,您可以在 rawCalendar1 上调用多个方法来检查返回值。
见https://developers.google.com/apps-script/reference/url-fetch/http-response
getContentText() 将 HttpResponse 的内容转换为类型 'string'。同样,Logger.log() 将括号之间的内容转换为 'string',这与在其上调用 getContentText() 基本相同。