0

It says I have a Missing ; before statement on the "var api =..." line. I'm not sure what else it is I need to do. If you need to see the rest of the script, please let me know. I will gladly submit everything else.

function askWolframAlpha_(q, app) {

try {

var api = "http://api.wolframalpha.com/v2/query?podindex=2&format=plaintext&appid=" + 67ULAK-L9R928PL76 + "&input=" + encodeURIComponent(q);
var response = UrlFetchApp.fetch(api, {
  muteHttpException: true
});

// Parse the XML response
if (response.getResponseCode() == 200) {
  var document = XmlService.parse(response.getContentText());
  var root = document.getRootElement();
  if (root.getAttribute("success").getValue() === "true") {
    return root.getChild("pod").getChild("subpod").getChild("plaintext").getText();
  }
}
} catch (f) {}
return false;
}
  • 1
    `67ULAK-L9R928PL76` is not a valid string or identifier. You probably want to remove the quotes and `+`s surrounding that so it's in the string itself. – Mike Cluck May 17 '16 at 22:36

1 Answers1

1

The problem is the 67ULAK-L9R928PL76 in the following line:

var api = "http://api.wolframalpha.com/v2/query?podindex=2&format=plaintext&appid=" + 67ULAK-L9R928PL76 + "&input=" + encodeURIComponent(q);

Change to:

var api = "http://api.wolframalpha.com/v2/query?podindex=2&format=plaintext&appid=67ULAK-L9R928PL76&input=" + encodeURIComponent(q);

or at least to:

var api = "http://api.wolframalpha.com/v2/query?podindex=2&format=plaintext&appid=" + "67ULAK-L9R928PL76" + "&input=" + encodeURIComponent(q);
Nelson Teixeira
  • 6,297
  • 5
  • 36
  • 73