smugmug api json questions

bmsterlingbmsterling Registered Users Posts: 28 Big grins
Hey all,
I am working on adding SmugMug capablilities to a WordPress plugin that I developed (http://benjaminsterling.com/benjaminsterlinggalleries/) but I am having issues figuring out how to use the api.

The first issue I have is this, I am using the following url to connect to smugmug:
http://api.smugmug.com/hack/json/1.2.0/?APIKey=_APIKEY_&method=smugmug.login.anonymously

When I connect via the browser, I get a forced download file that is of working json:

{"stat":"ok","method":"smugmug.login.anonymously","Login":{"Session":{"id":"_SESSIONID_"}}}

But if I use the same url and try to grab it via php, I get:

{"result":"error","msg":"No Service Provided"}Not sure of the reasoning behind this.

Second issue/request is, does anyone have some example urls that they are using so I can figure out how to better structure my urls?

Lastly, I need to figure out what sizes are the images?
  • Small
  • Medium
  • Large
  • XLarge
  • X2Large
  • X3Large
  • Original
Thanks.

Comments

  • devbobodevbobo Registered Users, Retired Mod Posts: 4,339 SmugMug Employee
    edited January 18, 2008
    G'day Ben,

    Welcome to dgrin wave.gif
    bmsterling wrote:
    But if I use the same url and try to grab it via php, I get:

    {"result":"error","msg":"No Service Provided"}Not sure of the reasoning behind this.

    Can you please make sure that you actually queryed our api here, as our errors are returned in this format...

    {"stat":"fail","code":1,"message":""}
    bmsterling wrote:
    Second issue/request is, does anyone have some example urls that they are using so I can figure out how to better structure my urls?
    Not quite sure what you mean here, can you please elaborate.
    bmsterling wrote:
    Lastly, I need to figure out what sizes are the images?
    • Small
    • Medium
    • Large
    • XLarge
    • X2Large
    • X3Large
    • Original

    If you are calling smugmug.images.getURLs or smugmug.images.get with Heavy options set, the image urls will be returned in the response

    SmallURL
    MediumURL
    LargeURL
    XLargeURL
    .. etc

    If one or more isn't in the response, that image size is not available.

    One thing I thought I would mention, if you are using PHP have you considered using our php api ? Instead doing whatever JSON response conversion, you simply call unserialize() on the response to turn it into a php array/object.

    Let me know if you have any other questions.

    Cheers,

    David
    David Parry
    SmugMug API Developer
    My Photos
  • bmsterlingbmsterling Registered Users Posts: 28 Big grins
    edited January 19, 2008
    devbobo,
    Thanks for the response.

    I wound up finding a old post that had the max size of each image, ie Small == up to 100px x up to 100px.
    Not quite sure what you mean here, can you please elaborate.

    I was trying to figure out what structure the url had to be in to make calls to the api. I looked at that api docs and there are not a lot of good examples on how to make certain calls. I came across a page the has Feed calls, so that may point me in the right direction, but I needed more info on what each call would do and how I should structure the url to make said calls.
    One thing I thought I would mention, if you are using PHP have you considered using our php api ? Instead doing whatever JSON response conversion, you simply call unserialize() on the response to turn it into a php array/object.

    The way my plugin works is that a user will enter in a feed url or enter in a bunch of parameters and the code will build the url, then that url is sent to the server via AJAX and a JSON resonse is sent back. If the server does not handle certain functions (which a surprisingly a large amount don't) the javascript code will execute a JSONP (cross-domain) call, which I believe the SmugMug API does not support just yet. So the url must return a JSON formated string.

    I have been successful at bringing in an RSS feed for my gallery and then converting it to an array then to a json string, so I have basic support for SmugMug in my plugin. But I need to give an advanced options set which will allow for keywords, selecting an album list, selecting all photos or just some, and so on.

    As it stands now, the purpose is for a user to only grab images from their account, so I just need to figure out how to achieve that.

    Thanks.
  • bmsterlingbmsterling Registered Users Posts: 28 Big grins
    edited January 19, 2008
    I actually just found a reference to a json call back at this post, but could not find a reference to it in the api docs.

    I also did some more reading in that thread and see some reference to the session id, but the question is, do I need the session id if I am only getting images? This means that I need to make two calls to the server, one to get the session id and another to get the photos, am I correct in this assumption?
  • devbobodevbobo Registered Users, Retired Mod Posts: 4,339 SmugMug Employee
    edited January 19, 2008
    bmsterling wrote:
    I actually just found a reference to a json call back at this post, but could not find a reference to it in the api docs.

    I also did some more reading in that thread and see some reference to the session id, but the question is, do I need the session id if I am only getting images? This means that I need to make two calls to the server, one to get the session id and another to get the photos, am I correct in this assumption?

    yes, that's correct
    David Parry
    SmugMug API Developer
    My Photos
  • cabbeycabbey Registered Users Posts: 1,053 Major grins
    edited January 20, 2008
    bmsterling wrote:
    I was trying to figure out what structure the url had to be in to make calls to the api.

    From what I can tell, the structure doesn't matter as long as it's a legit http request. I've put the method first and last, the session in an argument variable or in a cookie, nothing seems to matter as long as you send everything that's required and do it in a legal http request.
    SmugMug Sorcerer - Engineering Team Champion for Commerce, Finance, Security, and Data Support
    http://wall-art.smugmug.com/
  • bmsterlingbmsterling Registered Users Posts: 28 Big grins
    edited January 22, 2008
    Thanks to you both, I think I have it working pretty well now.
Sign In or Register to comment.