Options

Need info on SmugMug API in JavaScript (AJAX):

flyingdutchieflyingdutchie Registered Users Posts: 1,286 Major grins
Hello Smugmuggers :):

Is there any documentation on how to use the AJAX api in JavaScript?
E.g. smugmug.js provides this javascript function:
function ajax_query(callbackFunction, url, postArray, asText)
{ 
...
}
 

I found these examples of usages of this function:
postArray = new Array();
postArray['tool'] = 'editBio';
postArray['UserID'] = 8381;
postArray['newBio'] = 'update bio';
postArray['settings'] = 'bio';
postArray['Bio'] = newBio;
ajax_query(handleJS, webServer+'/hack/RPC/[b]home.mg[/b]', [b]postArray[/b], true);
...
...
postArray = new Array();
postArray['tool'] = 'editTitle';
postArray['TypeID'] = AlbumID;
postArray['Title'] = encodeURIComponent(document.getElementById('newTitle').value);
ajax_query(handleJS, webServer+'/hack/RPC/[b]gallery.mg[/b]', [b]postArray[/b], true);
 

Is there any documentation that exactly describes which requests the ajax_query function supports, documentation that describes what the valid values are for url and postArray?

Thank you very much!
-- Anton.
I can't grasp the notion of time.

When I hear the earth will melt into the sun,
in two billion years,
all I can think is:
    "Will that be on a Monday?"
==========================
http://www.streetsofboston.com
http://blog.antonspaans.com

Comments

  • Options
    flyingdutchieflyingdutchie Registered Users Posts: 1,286 Major grins
    edited September 26, 2005
    Hello Smugmuggers :):

    Is there any documentation on how to use the AJAX api in JavaScript?
    E.g. smugmug.js provides this javascript function:
    function ajax_query(callbackFunction, url, postArray, asText)
    { 
    ...
    }
     
    

    I found these examples of usages of this function:
    postArray = new Array();
    postArray['tool'] = 'editBio';
    postArray['UserID'] = 8381;
    postArray['newBio'] = 'update bio';
    postArray['settings'] = 'bio';
    postArray['Bio'] = newBio;
    ajax_query(handleJS, webServer+'/hack/RPC/[b]home.mg[/b]', [b]postArray[/b], true);
    ...
    ...
    postArray = new Array();
    postArray['tool'] = 'editTitle';
    postArray['TypeID'] = AlbumID;
    postArray['Title'] = encodeURIComponent(document.getElementById('newTitle').value);
    ajax_query(handleJS, webServer+'/hack/RPC/[b]gallery.mg[/b]', [b]postArray[/b], true);
     
    

    Is there any documentation that exactly describes which requests the ajax_query function supports, documentation that describes what the valid values are for url and postArray?

    Thank you very much!
    -- Anton.

    ...bump...

    nobody...? ... is there no documentation ...?
    I can't grasp the notion of time.

    When I hear the earth will melt into the sun,
    in two billion years,
    all I can think is:
        "Will that be on a Monday?"
    ==========================
    http://www.streetsofboston.com
    http://blog.antonspaans.com
  • Options
    flyingdutchieflyingdutchie Registered Users Posts: 1,286 Major grins
    edited October 6, 2005
    ...bump...

    nobody...? ... is there no documentation ...?
    ...bump number 2...
    I can't grasp the notion of time.

    When I hear the earth will melt into the sun,
    in two billion years,
    all I can think is:
        "Will that be on a Monday?"
    ==========================
    http://www.streetsofboston.com
    http://blog.antonspaans.com
  • Options
    {JT}{JT} Registered Users Posts: 1,016 Major grins
    edited October 8, 2005
    There is no documentation, because we are not ready to provide AJAX as a viable API yet :) We oureselves just rolled it out and are still deciding what we like/need/etc. I am sure we will be expanding our use of it and Don can make the call on if he'd like to document it's use.
    ...bump number 2...
  • Options
    avonwyssavonwyss Registered Users Posts: 12 Big grins
    edited October 8, 2005
    Is there any documentation on how to use the AJAX api in JavaScript?
    Of course, if you want to use AJAX (which does not define the protocol, btw., but the technology), you can use AJAX over XML-RPC. You may want to have a look at the JSolait JavaScript library which also has an XML-RPC wrapper for you to use, so that you can use the standard XML-RPC API for AJAX communications.
  • Options
    flyingdutchieflyingdutchie Registered Users Posts: 1,286 Major grins
    edited October 13, 2005
    avonwyss wrote:
    Of course, if you want to use AJAX (which does not define the protocol, btw., but the technology), you can use AJAX over XML-RPC. You may want to have a look at the JSolait JavaScript library which also has an XML-RPC wrapper for you to use, so that you can use the standard XML-RPC API for AJAX communications.
    Thanks for the pointer, but Smugmug already has implemented that by including smugmug.js. This javascript file defines the function ajax_query(...) and it does all the dirty work already.
    I'm just curious which services Smugmug has made availble using this API: What are the valid values for postArray; What are the value URLs to invoke the services; etc.

    -- Anton.
    I can't grasp the notion of time.

    When I hear the earth will melt into the sun,
    in two billion years,
    all I can think is:
        "Will that be on a Monday?"
    ==========================
    http://www.streetsofboston.com
    http://blog.antonspaans.com
  • Options
    flyingdutchieflyingdutchie Registered Users Posts: 1,286 Major grins
    edited August 6, 2006
    Thanks for the pointer, but Smugmug already has implemented that by including smugmug.js. This javascript file defines the function ajax_query(...) and it does all the dirty work already.
    I'm just curious which services Smugmug has made availble using this API: What are the valid values for postArray; What are the value URLs to invoke the services; etc.

    -- Anton.

    Any news on this front?:D
    I can't grasp the notion of time.

    When I hear the earth will melt into the sun,
    in two billion years,
    all I can think is:
        "Will that be on a Monday?"
    ==========================
    http://www.streetsofboston.com
    http://blog.antonspaans.com
  • Options
    devbobodevbobo Registered Users, Retired Mod Posts: 4,339 SmugMug Employee
    edited August 7, 2006
    Any news on this front?:D

    Anton,

    BWG and myself have used this function for a number of hacks. But basically, it's been matter of reverse engineering any existing calls.

    As a side note, it is possible to pass a null values as the postArray, when you are just retrieving the source to a particular SM page like in this example.

    Cheers,

    David
    David Parry
    SmugMug API Developer
    My Photos
  • Options
    flyingdutchieflyingdutchie Registered Users Posts: 1,286 Major grins
    edited August 7, 2006
    devbobo wrote:
    Anton,

    BWG and myself have used this function for a number of hacks. But basically, it's been matter of reverse engineering any existing calls.

    As a side note, it is possible to pass a null values as the postArray, when you are just retrieving the source to a particular SM page like in this example.

    Cheers,

    David

    Thanks David!

    > "Any existing calls"
    Which calls are these calls? I can find no (comprehensive) set of example. Except the few that deal with changing caption, keywords, album-desc, etc.

    -- Anton.
    I can't grasp the notion of time.

    When I hear the earth will melt into the sun,
    in two billion years,
    all I can think is:
        "Will that be on a Monday?"
    ==========================
    http://www.streetsofboston.com
    http://blog.antonspaans.com
  • Options
    devbobodevbobo Registered Users, Retired Mod Posts: 4,339 SmugMug Employee
    edited August 7, 2006
    Which calls are these calls? I can find no (comprehensive) set of example. Except the few that deal with changing caption, keywords, album-desc, etc.

    Anton,

    Apart from the different version of ajax.js that can be found in different places. We also found this found being in the lightbox and the full screen slideshow.

    The lightbox code gets used in my BZT hack to load the image info, so that i can scale the thumb correctly...
        postArray = new Array();
        postArray['tool'] = 'lightBoxImage';
        postArray['ImageID'] = thumbnail;
        postArray['size'] = 'Original';
        postArray['pageType'] = pageType;
        postArray['pageTypeDetails'] = pageTypeDetails;
        postArray['siteUser'] = siteUser;
        ajax_query(processThumbnailEXIF, webServer+'/hack/RPC/gallery.mg', postArray, true);
    

    And this code is used in the slideshow hack...
      if (slideSourceIsGallery)
        ajax_query(slideshowHandler, '/photos/sspopup.mg?AlbumID=' + /\/gallery\/([0-9]+)/.exec(slideshowUrl)[1], null, true);
      else {
        var postArray = new Array();
        postArray['TemplateID'] = '8';
        postArray['origin'] = slideshowUrl;
        ajax_query(slideshowHandler, '/homepage/templatechange.mg', postArray, true);
      }
    

    Also, thinking about this further this morning, you can actually reverse engineer any form based submissions into ajax calls changing all the inputs in variables inside the postArray...Does that make sense ?

    We don't really have access to any list, BWG and I ended up go searching the source to find anything we can use/hack when the need arises.

    Hope this helps.

    Cheers,

    David
    David Parry
    SmugMug API Developer
    My Photos
  • Options
    flyingdutchieflyingdutchie Registered Users Posts: 1,286 Major grins
    edited August 8, 2006
    Thanks David! I really appreciate your help.

    I guess Smugmug does not make the list of AJAX callback public.... reverse engineering is the solution here.

    Would you know how to get a list of all your own galleries using AJAX, including the 'featured' photo?

    Thanks!
    -- Anton.
    I can't grasp the notion of time.

    When I hear the earth will melt into the sun,
    in two billion years,
    all I can think is:
        "Will that be on a Monday?"
    ==========================
    http://www.streetsofboston.com
    http://blog.antonspaans.com
  • Options
    jerryrjerryr Registered Users Posts: 595 Major grins
    edited August 19, 2007
    Hi -
    I thought I would 'dust off' this thread.
    My question is - has anyone ever used the ajax_query (or any
    other method for that matter) to obtain the filename for a specific image ???

    Thanks - jerryr
  • Options
    jerryrjerryr Registered Users Posts: 595 Major grins
    edited August 20, 2007
Sign In or Register to comment.