Update some Javascript uses to new Freebase API - part of #696

This commit is contained in:
Tom Morris 2013-03-12 17:46:18 -04:00
parent 05968e37fa
commit a06e16a9e5
5 changed files with 14 additions and 10 deletions

View File

@ -46,6 +46,7 @@ FreebaseLoadingDialog.prototype._createDialog = function() {
var authorization = this._elmts.authorization;
var loadButton = this._elmts.loadButton;
// TODO: Does this need to be redone for the new API / freebase.com site?
var check_authorization = function(cont) {
var check_authorization_url = "command/freebase/check-authorization/" + provider;
$.get(check_authorization_url, function(data) {

View File

@ -99,6 +99,8 @@ SchemaAlignment._batchSearch = function(queries, onDone) {
batch[key] = queries[key];
}
// TODO: New API doesn't accept multiple queries
// args.push("https://www.googleapis.com/freebase/v1/search?key=" + Freebase.API_KEY + "&" +
args.push("http://api.freebase.com/api/service/search?" +
$.param({ "queries" : JSON.stringify(batch) }) + "&callback=?");

View File

@ -340,15 +340,13 @@ SchemaAlignmentDialog.UILink.prototype._configureTarget = function() {
var dismissBusy = DialogSystem.showBusy();
$.getJSON(
"http://api.freebase.com/api/service/mqlread?query=" + JSON.stringify({
query: {
"https://www.googleapis.com/freebase/v1/mqlread?key="+ Freebase.API_KEY + "&query=" + JSON.stringify({
"id" : this._link.property.id,
"type" : "/type/property",
"expected_type" : {
"id" : null,
"name" : null,
"/freebase/type_hints/mediator" : null
}
}
}) + "&callback=?",
null,

View File

@ -33,12 +33,15 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
var Freebase = {};
Freebase.API_KEY = "AIzaSyBAZ_EjMPKlOzyyZXv6JKXPPwJFISVji3M";
Freebase.mqlread = function(query, options, onDone) {
var params = {};
var queryEnv = {
"query": query
};
// var queryEnv = {
// "query": query
// };
// TODO: Options need to be handled differently for new API - but this doesn't appear to be used
if (options) {
for (var n in options) {
if (options.hasOwnProperty(n)) {
@ -52,10 +55,10 @@ Freebase.mqlread = function(query, options, onDone) {
}
}
params.query = JSON.stringify(queryEnv);
params.query = JSON.stringify(query);
$.getJSON(
"http://api.freebase.com/api/service/mqlread?" + $.param(params) + "&callback=?",
"https://www.googleapis.com/freebase/v1/mqlread?key=" + Freebase.API_KEY + $.param(params) + "&callback=?",
null,
onDone,
"jsonp"

View File

@ -89,8 +89,8 @@ DataTableColumnHeaderUI.extendMenu(function(column, columnHeaderUI, menu) {
"id" : data.id,
"type" : []
};
var baseUrl = "http://api.freebase.com/api/service/mqlread";
var url = baseUrl + "?" + $.param({ query: JSON.stringify({ query: query }) }) + "&callback=?";
var baseUrl = "https://www.googleapis.com/freebase/v1/mqlread?key=" + Freebase.API_KEY + "&";
var url = baseUrl + $.param({ query: JSON.stringify(query) }) + "&callback=?";
$.getJSON(
url,