So here is the "Example" for apps script External APIs.
https://developers.google.com/apps-script/external_apis
But when you cut-and-paste the code:
var url = "https://gdata.youtube.com/feeds/api/videos?"
+ "q=skateboarding+dog"
+ "&start-index=21"
+ "&max-results=10"
+ "&v=2";
var response = UrlFetchApp.fetch(url);
into a Code.gs
function myFunction() {
var url = "https://gdata.youtube.com/feeds/api/videos?"
+ "q=skateboarding+dog"
+ "&start-index=21"
+ "&max-results=10"
+ "&v=2";
var response = UrlFetchApp.fetch(url);
}
and press the "publish Deploy as Web app" (after managing the project) Nothing happens.
Is there a working example not just the above snippet? In other words what do you do with the response var to "Display" the query to YouTube etc? This URL-fetch example is said to be needed to understand numerous tutorial examples but doesn't itself actually accomplish anything.
Thanks
I responding here to the response to the answers below.
I tried Browser.msgBox(response); and that gives me "unknown macro doGet.”
I tried Logger.log(response); and that gives me “unknown macro doGet.”
function myFunction() {
var url = "https://gdata.youtube.com/feeds/api/videos?"
+ "q=skateboarding+dog"
+ "&start-index=21"
+ "&max-results=10"
+ "&v=2";
var response = UrlFetchApp.fetch(url);
//Browser.msgBox(response);
// Logger.log(response);
}
You say "that's up to you as a developer" But I don't know what it is supposed to do “as a developer”
Yes it's obvious i am missing something here, that is the problem. I am missing something fundamental that is assumed I should know from the example but I do not know it.
I was not introduced to Listbox in the tutorials.
When I type “listbox” into the search at /apps-script I get this example:
https://developers.google.com/apps-script/class_listbox
I put this into a spreadsheet and am able to Run it to get the selection choices. So why is this different from what I should get with msgbox, or logger? These both get me ‘Unknown macro doGet”
Please I am lost here. I need to undertand this before proceeding with the other tutorials but am missing something.
OK I've found a way to get the "response" to show but not using the "Deploy as a web app" (which is what I think I need, but I guess i don't know.
function onOpen() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
// These are the 2 menu entries var menuEntries = [ {name: "Surprise 1", functionName: "menuItem1"}, {name: "Surprise 2", functionName: "menuItem2"}, {name: "Surprise 3", functionName: "menuItem3"} ];
// surprise3 is in another script
// After defining the menu entries, then you define the menu itself ss.addMenu("Surprises", menuEntries); }
function menuItem1() {
var url = "https://gdata.youtube.com/feeds/api/videos?"
+ "q=skateboarding+dog"
+ "&start-index=21"
+ "&max-results=10"
+ "&v=2";
var response = UrlFetchApp.fetch(url);
Browser.msgBox(response);
}
function menuItem2() {
var url = "https://gdata.youtube.com/feeds/api/videos?"
+ "q=skateboarding+dog"
+ "&start-index=21"
+ "&max-results=10"
+ "&v=2";
Browser.msgBox(url);
}
but all this does is print "FetchReponse" in the box from menu1. So?
How do I get this into a browser? I must have something wrong with "deploy to web" selection, correct?