Correct URL to download images via API

SperendSperend Registered Users Posts: 10 Big grins
I am working on a program where I need to display thumbs. If I want to download an image thumb via a ThumbURL (provided with smugmug.images.getURLs). But this is not possible.

What is the URL I must use to download (password protected) images? I have a sessionID, username, password, etc. Or is there an API command that I overlooked to download an image? (I am programming in Java, using the Kallasoft java API)

Help is very much appreciated.

Comments

  • SperendSperend Registered Users Posts: 10 Big grins
    edited September 8, 2008
    Anyone?
  • flyingdutchieflyingdutchie Registered Users Posts: 1,286 Major grins
    edited September 8, 2008
    Sperend wrote:
    I am working on a program where I need to display thumbs. If I want to download an image thumb via a ThumbURL (provided with smugmug.images.getURLs). But this is not possible.

    What is the URL I must use to download (password protected) images? I have a sessionID, username, password, etc. Or is there an API command that I overlooked to download an image? (I am programming in Java, using the Kallasoft java API)

    Help is very much appreciated.

    Be sure to set the URL's cookie before downloading the image.

    First obtain the java.net.URL of the thumbnail. The look at the code-snippet from my own SmugFig API below for more info about setting the cookie:
    /**
     * Sets the appropriate Smugmug cookie for downloading images from smugmug through URLs. 
     * @param urlConnection The url-connection to the image.
     */
    public void setCookie(URLConnection urlConnection) {
        urlConnection.setRequestProperty("Cookie", "SMSESS="+getSessionID());
    }
    /**
     * Opens the input stream from the provided URL and makes sure that Smugmug-cookies are set appropriately.
     * @param url The URL to an image.
     * @return The input-stream to that image.
     * @throws IOException
     */
    public InputStream openInputStream(URL url) throws IOException {
        final URLConnection urlConnection = url.openConnection();
        setCookie(urlConnection);
        return urlConnection.getInputStream();
    }
    

    The call to getSessionID() returns the string that is the session-id returned to you when you log-in into Smugmug using the API.

    After calling openInputStream(URL), you can use the returned input-stream to read the thumbnail's contents.
    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
  • SperendSperend Registered Users Posts: 10 Big grins
    edited September 9, 2008
    Thank you very much! It works like a charm now.

    Bedankt!
Sign In or Register to comment.