Github - 如何通过API搜索要点?

时间:2015-04-27 18:44:18

标签: github github-api gist

我理解使用Github API可以search a repository via various criteria但是如何搜索单个要点或找到它的ID?

理想情况下,我想使用userfilename,但它可能是内容正文中的哈希:

https://gist.github.com/search?q=sadjghasghdhjasgdfhs

1 个答案:

答案 0 :(得分:2)

我刚刚发现可以搜索特定的用户和/或文件名。我查看了使用Future<Results> mysqlAllTags = mysqlCon.query(query).then((results){ // Make new list as a part of the JsonObject json.tags = new List(); // Loop throught the row of the result from Mysql data return results.forEach((row){ // Create Map to put the word, value, rating and id into the JsonObject Map data = new Map(); // Put the Mysql data into the Map data["word"] = row.word.toString(); data["value"] = row.value.toString(); data["rating"] = row.rating.toString(); data["id_tag"] = row.id_tag.toString(); data["replacing"] = null; // Add the Map to the userPages list json.tags.add(data); }).then((e){ var futures = []; // added for(var tag in json.tags){ print("row "); print(json.tags); //Map dataReplacing = getReplacing(userId, row.id_tag.toString()); String replacingTags = getReplacingSQL(tag['id_tag'].toString()); // added `futures.add(...)` futures.add(mysqlCon.query(replacingTags).then((result) { result.forEach((row1){ Map map = new Map(); map["word"] = row1.word.toString(); map["value"] = row1.value.toString(); map["id_tag"] = row1.id_replacing_tag.toString(); tag["replacing"] = map; }).then((e){ print("then inner for called"); return null; }); print("then inner for called"); return null; })); } print("outer for returned"); // Send the data in UTF8 to the client result = Helpers.formatJsonAndEncodeUtf8('OK', session:_session, data: [json]); return Future.wait(futures); // added }).catchError((error){ result = Helpers.formatJsonAndEncodeUtf8('ERROR 856284555 (Could not load tags)', session:_session); }); }).catchError((error){ result = Helpers.formatJsonAndEncodeUtf8('ERROR 2346644555 (Could not load tags)', session:_session); }); return Future.wait([mysqlAllTags]).then((e){ print("future returned"); return result; }); user:some-user-name的github的高级搜索。这些标准也适用于要点搜索术语。

示例:https://gist.github.com/search?q=user%3Amanuelvanrijn+path%3Aguid.js

希望这有帮助,直到有一个搜索api可用于gists