Open TheBrockEllis opened 9 years ago
Hi,
Some browsers don’t like basic auth params passed in the url like that; try passing the access_token as a GET/POST parameter instead.
Regarding all API calls being POSTS, yes this is confusing, and it will change in the near future as we improve our API.
Hey there mateomurphy!
Thanks so much for the help! Popping the access token into the args for the getJSON worked like a charm. Here's what the function looks like now (for posterity's sake)
access_token: "234df4tr9fdg0-9asd0sdf09sd9s",
// Call the Planbox API
api: function(fname, args, onsuccess, onerror) {
var url = Planbox.base_url+'api/'+fname+'?callback=?';
args = args || {};
args.access_token = Planbox.access_token;
return $.getJSON(url, args, function(data) {
if (data && data.code == 'ok') {
if (onsuccess) onsuccess(data.content);
} else if (data && data.code == 'error') {
if (onerror) onerror(data.content);
} else {
if (onerror) onerror('Cannot reach Planbox');
}
}, "json");
},
Thanks so much for the help. Cant wait to start extending some things to match our workflow!
I was wondering if you could provide an example jQuery snippet that would be used to grab the products. I've been fiddling with the code in this repo, my own version of it as well as cURLing the the API and I can't seem to come up with the magical combination of access_token, username, password, email, GET/POST, etc.
Here is the closest thing I can (taken from this repo)
I'm just very confused about the using POST when the intention is to return data and not submit anything. Any clarification would be amazing.