开发者

How can I query the Best Buy Remix API w/ jQuery?

Here's the code that I've been trying to work with:

$.getJSON("http://api.remix.bestbuy.com/v1/products(search=" + escape(searchCriteria) + ")?apiKey=" + hhApiKey + "&format=json&callback=?", 
function(data) {
    if(data.error) {
        alert("I'm sorry, there was an error processing your request.");
    } else {
        alert(data);
    }
});

However, the data that comes back has an error because it doesn't understand the requested URL. I looked at the net tab in Firebug and here's the URL it's trying to call out to:

http://api.remix.bestbuy.com/v1/products(search=digital%20camera)?apiKey=myapikey&format=json&callback=json1264868431&_1254866270659=

I t开发者_开发技巧hink the problem lays in the bolded section which is being added on for no reason as far as I can tell. I think the Remix API sees it and thinks it's a botched parameter. Is there any way to stop that from being added?


When disabling the cache setting for jQuery ajax it will attempt to append a timestamp to the querystring. This may be the problem your experiencing. Try calling the function with caching explicitly enabled.

$.ajax({
    type: "GET",
    url: "http://api.remix.bestbuy.com/v1/products(search=" + escape(searchCriteria) + ")?apiKey=" + hhApiKey + "&format=json&callback=?",
    cache: true,
    success: function() {
        alert('success');
    },
    dataType: 'json'
}); 


I've just gone to that URL and it says "403 Developer Inactive". Could you be needing to do an API developer registration to get through and is your account active?

A lot of these API requests (Netflix) require you to login in first, and it will assign you a session id to include in your querystring. Could it be you're not logged

Sorry if these seem like obvious questions, I'm just throwing some ideas out there.


There are 2 problems with the Remix API query stated above: the "&" and the "underscore" in the JSON callback. The "&" makes the API think it is a new parameter that it does not understand. The "underscore" in any JSON callback will cause the Remix query parser to return a "couldn't understand . . ." error.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜