使用API​​密钥的问题

时间:2017-02-20 01:10:06

标签: api google-apps-script

我在尝试访问AgroPortal的ontologias时遇到了一些困难,它说我的api密钥无效但是我创建了一个帐户,它被给了我一个api密钥。

我尝试像BioIortal那样做,因为API是相同的,但是使用BioPortal,我的代码是这样的:

function getAgroPortalOntologies() {

var searchString = "http://data.agroportal.lirmm.fr/ontologies?apikey=72574b5d-b741-42a4-b449-4c1b64dda19a&display_links=false&display_context=false";

// we cache results and try to retrieve them on every new execution.
var cache = CacheService.getPrivateCache();

var text;

if (cache.get("ontologies_fragments") == null) {
    text = UrlFetchApp.fetch(searchString).getContentText();
    splitResultAndCache(cache, "ontologies", text);
} else {
    text = getCacheResultAndMerge(cache, "ontologies");
}

var doc = JSON.parse(text);
var ontologies = doc;

var ontologyDictionary = {};
for (ontologyIndex in doc) {
    var ontology = doc[ontologyIndex];
  ontologyDictionary[ontology.acronym] = {"name":ontology.name, "uri":ontology["@id"]};
}

return sortOnKeys(ontologyDictionary);

}

var result2 = UrlFetchApp.fetch("http://data.agroportal.lirmm.fr/annotator", options).getContentText();

我对BioPortal做的非常相似,我这样做了:

function getBioPortalOntologies() {

var searchString = "http://data.bioontology.org/ontologies?apikey=df3b13de-1ff4-4396-a183-80cc845046cb&display_links=false&display_context=false";

// we cache results and try to retrieve them on every new execution.
var cache = CacheService.getPrivateCache();

var text;

if (cache.get("ontologies_fragments") == null) {
    text = UrlFetchApp.fetch(searchString).getContentText();
    splitResultAndCache(cache, "ontologies", text);
} else {
    text = getCacheResultAndMerge(cache, "ontologies");
}

var doc = JSON.parse(text);
var ontologies = doc;

var ontologyDictionary = {};
for (ontologyIndex in doc) {
    var ontology = doc[ontologyIndex];
  ontologyDictionary[ontology.acronym] = {"name":ontology.name, "uri":ontology["@id"]};
}

return sortOnKeys(ontologyDictionary);

}

var result = UrlFetchApp.fetch("http://data.bioontology.org/annotator", options).getContentText();

有人可以帮助我吗?

谢谢,我的问候。

0 个答案:

没有答案