smugmug.images.changeSettings

verseguruverseguru Registered Users Posts: 3 Beginner grinner
Can anyone confirm if this method actually works? I've tried a multitude of different structures, endpoints, and both XML-RPC and REST, all with no luck. I just get a system error. Judging from prior forum posts it's a bit erratic, but it's the only way to add Keywords it seems (other than IPTC) so I'd like to get it working.

Comments

  • luke_churchluke_church Registered Users Posts: 507 Major grins
    edited December 28, 2005
    Confrimation + Workaround
    It didn't work the last time I looked (15-Dec-05). I posted a bug report on the 13-Sep-05 describing what is probably a related problem. Someone else commented on the same problem on 23-Aug-05.

    Here's most of an email I wrote explaining a nasty hack to work around the problem:

    So the 'work around': it uses HTTP POST to behave roughly like the browser does when updating the keywords. It was derived from capturing the chatter between IE and Smugmug.

    The only issue is that if you release code that depends upon this and then Smugmug change the way the site works things may break.

    Anyhow, in C# (should translate fairly easily into anything else):
    //Use your session ID instead
    String sessionID = "...";
    //Use your image ID
    int imageID = 48342798;
    //Create a communications client
    System.Net.WebClient webClient = new System.Net.WebClient();

    //Give it the address to talk to
    webClient.BaseAddress = "http://www.smugmug.com/photos/tools.mg";

    //Give it the access credentials
    webClient.Headers.Add("Cookie:SMSESS=" + sessionID);

    //Create a collection of information to pass System.Collections.Specialized.NameValueCollection queryStringCollection =
    new System.Collections.Specialized.NameValueCollection();
    //Populate the collection with desired data queryStringCollection.Add("Caption", "new caption added via POST"); queryStringCollection.Add("Keywords", "tentacles camel sheep"); //Keywords

    //And parameters that Smugmug need to do their work queryStringCollection.Add("tool", "caption"); queryStringCollection.Add("ImageID", imageID.ToString());
    //Push the data to Smugmug
    byte[] responseArray =
    webClient.UploadValues("http://www.smugmug.com/photos/tools.mg", "POST", queryStringCollection);

    //Now do something intelligent with responseArray

    Hope this helps

    All the best,
    Luke
  • verseguruverseguru Registered Users Posts: 3 Beginner grinner
    edited January 1, 2006
    Luke,

    Thanks for this, it looks like a decent solution and one that doesn't involve unnecessary scraping—even though it isn't a documented API…

    Cheers!
  • NikolaiNikolai Registered Users Posts: 19,035 Major grins
    edited January 1, 2006
    Good one. Luke!
    It didn't work the last time I looked (15-Dec-05). I posted a bug report on the 13-Sep-05 describing what is probably a related problem. Someone else commented on the same problem on 23-Aug-05.
    Luke

    Very neat! thumb.gif
    Happy New Year!
    "May the f/stop be with you!"
Sign In or Register to comment.