• Gear
  • Shots
  • Photo Craft
  • Video
  • Wide Angle
  • Support
  • New Stuff
  • More

Need some help with your New SmugMug Site?

Dgrin Challenges

Our Challenges moderator has lined up an new set of challenges for you. The Weekly Word Challenge. Get all the details and participate in the conversation Weekly Word Challenge.

Past DSS Challenge Winners, DSS Challenge Rules, and other important DSS Challenge information is here.

Looking for a little challenge? The Dgrin Mini-Challenges are a great way to challenge yourself. Take a moment to look through past winners and find the current Mini Challenge here.

From Around the Net

Enjoy a few of our favorite articles from around the 'net. If you have something you think we should see, post it here and we'll have a look.

Journeys

Landscapes

Sports

 
Thread Tools Display Modes
Old Apr-30-2007, 08:51 AM
#1
pmonday is offline pmonday OP
Big grins
Huh JSON Examples?
I'm relatively naive ( ) on JSON could use a couple questions answered. I am trying to build a SmugMap-like interface from blogs.sun.com/blackbox. The RSS feed has the exact information I need, but you can't load it from a web page because of the security implications (this thread documents it a bit, http://www.dgrin.com/showthread.php?...ghlight=access)

So, the JSON questions I have
  • Should the JSON API be able to get around this (I am guessing it will not since you are doing essentially the same thing from a security perspective...)
  • I need a jump start and can find 0 documentation on using the JSON API in the 1.2.0 API documents (examples are the most critical), am I missing something on the web site? Especially a jump start for folks like me trying to consume smugmug information from a non-smugmug site :-) Or, now that I'm looking at the APIs, is the idea that we should be viewing the page source and working with the API examples under the specific method we want to be using?
Thanks,
Paul Monday
Old May-01-2007, 11:09 AM
#2
pmonday is offline pmonday OP
Big grins
Follow-up, Chattin' with myself
In talking with a few folks here and looking around the net a bit, it looks like pure use of JSON still requires that I load the document from a different domain, thus forcing the sandbox security violation...bummer for me.

The solution, theoretically (with respect to JSON), is JSONP...but this appears to be enabled by the server side (y'all at SmugMug)...

Alternatives appear to be
- I could author a proxy javascript somewhere and put it on our server (not possible since I'm pure client side but is very similar to what I'm doing today anyway)

- I could use some IFrame hack that I don't understand yet (and I'm not sure if I could implement in the blogging infrastructure)

Still trying to figure this out though...there's got to be a more direct way to replace my current polling application on my pc that reformats info into javascript variables, uploading it to a middle-man web site and importing the .js from my client.

I suspect the google maps api, while not json, is a bit more like one would expect a pure client API to be like (import a javascript library and use it directly). That's an interesting solution since, technically, it seems like you have the same so called security violation as the remote document loading

Paul
Old May-01-2007, 11:47 AM
#3
komy is offline komy
Big grins
You should be able to use this library to get around the cross domain security issue from your server .

http://www.xml.com/pub/a/2005/12/21/...cript-tag.html

Kevin
Old May-06-2007, 08:13 PM
#4
pmonday is offline pmonday OP
Big grins
Quote:
Originally Posted by komy
You should be able to use this library to get around the cross domain security issue from your server .

http://www.xml.com/pub/a/2005/12/21/...cript-tag.html

Kevin
I believe that this is dependent on server side support. The example they use is from another JSON service. One of the parameters is a callback=javascriptobject where the javascript object can be a function. The server then wraps the JSON result in a function call so that it is called on the return of the information.

Here is the example of the callback function supported in a json service:
http://developer.yahoo.com/common/js...#callbackparam

Here is another example in the Google service:
http://googlemapsapi.blogspot.com/20...side-maps.html

Is there support for a callback on the SmugMug JSON API, I didn't see it anywhere?

Paul
Old May-06-2007, 11:17 PM
#5
devbobo is online now devbobo
LR whisperer
devbobo's Avatar
Quote:
Originally Posted by pmonday
I believe that this is dependent on server side support. The example they use is from another JSON service. One of the parameters is a callback=javascriptobject where the javascript object can be a function. The server then wraps the JSON result in a function call so that it is called on the return of the information.

Here is the example of the callback function supported in a json service:
http://developer.yahoo.com/common/js...#callbackparam

Here is another example in the Google service:
http://googlemapsapi.blogspot.com/20...side-maps.html

Is there support for a callback on the SmugMug JSON API, I didn't see it anywhere?

Paul
you don't need the callback.

var oJSON = eval('(' + response + ')');

also, you might want to read this article about how to proxy xmlhttp requests to get around cross domain security.
__________________
David Parry
SmugMug API Developer
My Photos
Old May-07-2007, 03:26 AM
#6
aarone is offline aarone
Big grins
aarone's Avatar
Quote:
you don't need the callback.

var oJSON = eval('(' + response + ')');
...which assumes you get 'response' using xmlhttprequest. The point of a callback in the yahoo API is to eliminate the need for xmlhttpreq and proxy by having the remote yahoo script invoke the callback function defined in the local script. The basic trick here is that scripts can be loaded across domains.

you might want to read this article about yahoo's json api.
Old May-07-2007, 07:03 AM
#7
pmonday is offline pmonday OP
Big grins
Quote:
Originally Posted by aarone
...which assumes you get 'response' using xmlhttprequest. The point of a callback in the yahoo API is to eliminate the need for xmlhttpreq and proxy by having the remote yahoo script invoke the callback function defined in the local script. The basic trick here is that scripts can be loaded across domains.

you might want to read this article about yahoo's json api.
I do NOT have access to the web server to host the proxy (i'm on blogs.sun.com and do not own the infrastructure). I am purely in the client space. Use of the callback mechanism in the Yahoo API (and Google) allows me to build a pure client rather than having to load a special proxy script on my web server. As aarone notes, by having YOUR JSON request format the callback, it calls my function, which is permitted by the sandboxes (I still don't see why since it seems like a huge security no-no...but hey, I'm going to go with it).
Old May-07-2007, 01:41 PM
#8
devbobo is online now devbobo
LR whisperer
devbobo's Avatar
Quote:
Originally Posted by aarone
...which assumes you get 'response' using xmlhttprequest. The point of a callback in the yahoo API is to eliminate the need for xmlhttpreq and proxy by having the remote yahoo script invoke the callback function defined in the local script. The basic trick here is that scripts can be loaded across domains.

you might want to read this article about yahoo's json api.
Thanks....that's cool.

I'm adding a JSONCallback parameter, I will let you know when it's released.
__________________
David Parry
SmugMug API Developer
My Photos
Old May-07-2007, 07:46 PM
#9
pmonday is offline pmonday OP
Big grins
Quote:
Originally Posted by devbobo
Thanks....that's cool.

I'm adding a JSONCallback parameter, I will let you know when it's released.
Thanks David...I hate to be an anxious dork, but our new tour starts at the end of this week and I have to finish the code while I'm in the booth at JavaOne, do these type of enhancements usually take a while?

Thanks,
Paul
Old May-08-2007, 05:36 AM
#10
aarone is offline aarone
Big grins
aarone's Avatar
Quote:
Originally Posted by devbobo
I'm adding a JSONCallback parameter, I will let you know when it's released.
awesome! thanks so much!
Old May-11-2007, 04:05 PM
#11
devbobo is online now devbobo
LR whisperer
devbobo's Avatar
Quote:
Originally Posted by aarone
awesome! thanks so much!
The JSONCallback parameter is now live.
__________________
David Parry
SmugMug API Developer
My Photos
Tell The World!  

Thread Tools
Display Modes

Posting Rules  
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump