0

Does anyone know if something has changed in the NYT API access, or how to reroute access to the API so that the connection is successful?

For my MFA thesis a couple years ago, I was scripting NYT API data into InDesign, using the Extendables library, and it worked great to call the necessary API URL. Now, after some time not using the scripts I'd written, the "http.get()" no longer seems to make the connection, and I receive an error from the Extendables "index.jsx" (from within the "core-packages/http/lib" file structure) and the "this.process_headers = function () {" which highlights "this.status = raw_head[0].split(' ')[1].to('int');" which returns "undefined is not an object" in ESTK.

A snippet of my code is:

var article_callURL = String(ny_article_search_baseURL + "&begin_date=" + begin_date + "&end_date=" + end_date + "&page=" + offset + sort_oldest + ny_article_key);
$.writeln(article_callURL);
//==Using extendables.jsx
var http = require("http");
var article_response = http.get(article_callURL);
if (article_response.status_code == 200) {
    $.writeln(article_response.body);
} else {
    $.writeln("Connection failed");
}

ESTK will write the article_callURL, but never gets passed the var http = require("http"); code. If someone could help me resolve this, it'd be greatly appreciated.

Karlen Kishmiryan
  • 7,322
  • 5
  • 35
  • 45
s.vd.z
  • 3
  • 6
  • What if you call the concatenated url into the browser. Does this work ? – Loic Jun 30 '16 at 12:08
  • Hey Loic. Yes, the concatenated URL (which i'm writing to the ESTK console) does works when pasted into a web browser, producing the JSON output I'm trying to parse into INDD. – s.vd.z Jun 30 '16 at 12:49
  • Try getUrl from Rorohiko and see if that works better : http://rorohiko.blogspot.fr/2013/01/geturlsjsx.html – Loic Jun 30 '16 at 14:24
  • Thanks. Tried, removing the "Main" func from the code so that it doesn't try to read an open .indd. I then use this: var callURL = String(ny_article_search_baseURL + "&begin_date=" + begin_date + "&end_date=" + end_date + "&page=" + offset + sort_oldest + ny_article_key); $.writeln(article_callURL); var article_response = GetURL(callURL); $.writeln(article_response.body); Removing ".body" from "$.writeln(article_response.body)" the Console prints the concatenated URL + "[object Object]". Keeping ".body" in, I get the URL w/out "[object Object]". I'm still not getting data. – s.vd.z Jun 30 '16 at 15:33
  • Would you mind sharing the url for trying ? – Loic Jul 01 '16 at 09:46
  • Hey. Thanks for the help. I'd rather not put out my API Key over the whole forum, so I'ver X'd it out after the "=": [http://api.nytimes.com/svc/search/v2/articlesearch.json?&begin_date=20160628&end_date=20160628&page=0&sort=oldest&api-key=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX] If you don't mind, you can get an API Key very quickly here: [http://developer.nytimes.com/signup] – s.vd.z Jul 01 '16 at 10:15
  • @Loic: FYI — it seems the link (even with the "XXXXX" replacing the actual api key) retrieves the JSON data from the API. – s.vd.z Jul 01 '16 at 15:31

0 Answers0