Skip to content

Commit

Permalink
updated Freebase example for newer API (changed since I wrote this book)
Browse files Browse the repository at this point in the history
  • Loading branch information
mark-watson committed Nov 14, 2013
1 parent df90ba3 commit 9ed0b46
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/com/knowledgebooks/info_spiders/FreebaseClient.java
Expand Up @@ -18,11 +18,11 @@
*/

public class FreebaseClient {
static final String URL = "http://www.freebase.com/api/service/mqlread";

static final String URL = "https://www.googleapis.com/freebase/v1/mqlread";

public JSON query(String json) throws Exception {
String envelope = "{\"qname\":{\"query\":" + json + "}}";
String urlStr = URL + "?queries=" + URLEncoder.encode(envelope, "UTF-8");
String urlStr = URL + "?query=" + URLEncoder.encode(json, "UTF-8");
URL url = new URL(urlStr);
URLConnection con = url.openConnection();
con.connect();
Expand Down
2 changes: 1 addition & 1 deletion test/TestFreebase.java
Expand Up @@ -5,7 +5,7 @@ public class TestFreebase {
public static void main(String[] args) {
try {
FreebaseClient t = new FreebaseClient();
JSON r = t.query("[{ \"/people/person/date_of_birth\":null, \"/people/person/gender\":null, \"/people/person/place_of_birth\":null, \"/people/person/profession\":\"biologist\", \"name\":null }] ");
JSON r = t.query("{\"type\":\"/people/person\",\"id\":\"/en/madonna\",\"children\":[]}");
System.out.println(r);
} catch (Exception e) {
e.printStackTrace();
Expand Down

0 comments on commit 9ed0b46

Please sign in to comment.