-
Notifications
You must be signed in to change notification settings - Fork 0
/
SearchQuery.pde
29 lines (26 loc) · 927 Bytes
/
SearchQuery.pde
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// Search wrapper provided from the LMC 2700 assignment
public class SearchQuery {
private String apikey = "59fd11cdc4f6368286cec6cd480d4480";
private String searchQuery;
private String searchFilter;
private int numPages;
// Constructor
public SearchQuery(String qu, int n) {
searchQuery = qu;
numPages = n;
//Use this filter to narrow your search.
searchFilter = "sourceResource.description=";
}
// Search function
public JSONArray search() {
String queryURL = "";
//Modify search query here. You will need to string query parameters
//together to get the JSON file you want.
queryURL = "http://api.dp.la/v2/items?" + searchFilter + searchQuery
+ "&api_key=" + apikey + "&page_size=" + numPages;
println("Search: " + queryURL);
JSONObject dplaData = loadJSONObject(queryURL);
JSONArray results = dplaData.getJSONArray("docs");
return results;
}
}