No login method using XMLRPC with v1.2.2 API

tullmanntullmann Registered Users Posts: 11 Big grins
I'm using Python with the XMLRPC API. I have code that mostly works with v1.2.1. I'm trying to see if upgrading to v1.2.2 fixes some session management problems, but I can't even invoke "smugmug.login.withPassword" against the 1.2.2 API. I get:

<methodResponse><fault><value><struct><member><name>faultString</name><value><string>server error. method not found.\n\nsmugmug.login.withPassword</string></value></member><member><name>faultCode</name><value><int>-32601</int></value></member></struct></value></fault></methodResponse>

I'm using https://secure.smugmug.com/services/api/xmlrpc/1.2.2/ (api.smugmug.com doesn't work either). I'm happy to paste in the 20-line Python script that demonstrates this if that helps.

Anyone having success with XMLRPC v1.2.2?

Comments

  • devbobodevbobo Registered Users, Retired Mod Posts: 4,339 SmugMug Employee
    edited November 29, 2010
    yes, if you please provide the code that you are using it will make it easier to debug.

    Thanks,

    David
    David Parry
    SmugMug API Developer
    My Photos
  • tullmanntullmann Registered Users Posts: 11 Big grins
    edited November 30, 2010
    Here you go! You'll need to fix the API_KEY in the script, and then pass a user/pass combo on the command line. I've been using this with python 2.5.2 on Linux. Thanks for looking at this.


    #!/usr/bin/python
    #
    # v1.2.2 XMLRPC test for smugmug.login.withPassword

    import sys
    import httplib
    import xmlrpclib

    API_KEY="xxx"

    if len(sys.argv) < 3:
    print("test-v1.2.2.py <username> <password>")
    sys.exit(1)

    verbose=True

    # v1.2.1 works:
    client1 = xmlrpclib.ServerProxy("https://api.smugmug.com/services/api/xmlrpc/1.2.1/", verbose=verbose)
    session = client1.smugmug.login.withPassword(sys.argv[1], sys.argv[2], API_KEY)

    # v1.2.2 does not work:
    #client2 = xmlrpclib.ServerProxy("https://api.smugmug.com/services/api/xmlrpc/1.2.2/", verbose=verbose)
    #client2 = xmlrpclib.ServerProxy("http://api.smugmug.com/services/api/xmlrpc/1.2.2/", verbose=verbose)
    #client2 = xmlrpclib.ServerProxy("http://secure.smugmug.com/services/api/xmlrpc/1.2.2/", verbose=verbose)
    client2 = xmlrpclib.ServerProxy("https://secure.smugmug.com/services/api/xmlrpc/1.2.2/", verbose=verbose)

    print str(client2)

    session = client2.smugmug.login.withPassword(API_KEY, sys.argv[1], sys.argv[2])

    print session

    #eof
  • jfriendjfriend Registered Users Posts: 8,097 Major grins
    edited November 30, 2010
    tullmann wrote: »
    Here you go! You'll need to fix the API_KEY in the script, and then pass a user/pass combo on the command line. I've been using this with python 2.5.2 on Linux. Thanks for looking at this.


    #!/usr/bin/python
    #
    # v1.2.2 XMLRPC test for smugmug.login.withPassword

    import sys
    import httplib
    import xmlrpclib

    API_KEY="xxx"

    if len(sys.argv) < 3:
    print("test-v1.2.2.py <username> <password>")
    sys.exit(1)

    verbose=True

    # v1.2.1 works:
    client1 = xmlrpclib.ServerProxy("https://api.smugmug.com/services/api/xmlrpc/1.2.1/", verbose=verbose)
    session = client1.smugmug.login.withPassword(sys.argv[1], sys.argv[2], API_KEY)

    # v1.2.2 does not work:
    #client2 = xmlrpclib.ServerProxy("https://api.smugmug.com/services/api/xmlrpc/1.2.2/", verbose=verbose)
    #client2 = xmlrpclib.ServerProxy("http://api.smugmug.com/services/api/xmlrpc/1.2.2/", verbose=verbose)
    #client2 = xmlrpclib.ServerProxy("http://secure.smugmug.com/services/api/xmlrpc/1.2.2/", verbose=verbose)
    client2 = xmlrpclib.ServerProxy("https://secure.smugmug.com/services/api/xmlrpc/1.2.2/", verbose=verbose)

    print str(client2)

    session = client2.smugmug.login.withPassword(API_KEY, sys.argv[1], sys.argv[2])

    print session

    #eof
    I don't know anything about the Python library, but do you mean to have the API_KEY in a different parameter position in the client1 login line vs. the client2 login line?
    --John
    HomepagePopular
    JFriend's javascript customizationsSecrets for getting fast answers on Dgrin
    Always include a link to your site when posting a question
  • tullmanntullmann Registered Users Posts: 11 Big grins
    edited November 30, 2010
    jfriend wrote: »
    I don't know anything about the Python library, but do you mean to have the API_KEY in a different parameter position in the client1 login line vs. the client2 login line?

    Good eye. I was fiddling around with this and noticed the new doc has the API key as the first parameter. However, I haven't gotten far enough for it to do a parameter check and reject the call. I'm getting a fault that smugmug.login.withPassword doesn't even exist as a method. (That said, I've tried the the other order too, in case XMLRPC doesn't work like I think.)
  • jfriendjfriend Registered Users Posts: 8,097 Major grins
    edited November 30, 2010
    tullmann wrote: »
    Good eye. I was fiddling around with this and noticed the new doc has the API key as the first parameter. However, I haven't gotten far enough for it to do a parameter check and reject the call. I'm getting a fault that smugmug.login.withPassword doesn't even exist as a method. (That said, I've tried the the other order too, in case XMLRPC doesn't work like I think.)
    If you're talking about the Smugmug documentation, it's order has nothing to do with what your python library is expecting. That order is determined by the Python library, not by the Smugmug API. So, you should pass the parameters in the order the Python library expects, regardless of what version of the Smugmug API you are using. See the doc for your Python library (or look at the code).
    --John
    HomepagePopular
    JFriend's javascript customizationsSecrets for getting fast answers on Dgrin
    Always include a link to your site when posting a question
  • devbobodevbobo Registered Users, Retired Mod Posts: 4,339 SmugMug Employee
    edited November 30, 2010
    The API 1.2.2+ will only work with named parameters over XML-RPC. If python doesn't support named parameters for XML-RPC, I'd highly recommend looking at using something like json or simplejson as an alternative.
    David Parry
    SmugMug API Developer
    My Photos
  • tullmanntullmann Registered Users Posts: 11 Big grins
    edited December 1, 2010
    devbobo wrote: »
    The API 1.2.2+ will only work with named parameters over XML-RPC. If python doesn't support named parameters for XML-RPC, I'd highly recommend looking at using something like json or simplejson as an alternative.

    Do you have example XML of a named parameter call in XML-RPC? AFAICT, they're not supported by the protocol (I'm looking at http://www.xmlrpc.com/spec).

    We've been meaning to switch to json since it looks far more sane than XMLRPC, but its been easier to just tweak the existing code base. Perhaps this will be sufficient motivation. :)

    Thanks!
  • devbobodevbobo Registered Users, Retired Mod Posts: 4,339 SmugMug Employee
    edited December 1, 2010
    Changing this line of code will make it work...

    session = client2.smugmug.login.withPassword({"APIKey": API_KEY, "EmailAddress": sys.argv[1], "Password": sys.argv[2]})

    Cheers,

    David
    David Parry
    SmugMug API Developer
    My Photos
  • tullmanntullmann Registered Users Posts: 11 Big grins
    edited December 2, 2010
    devbobo wrote: »
    Changing this line of code will make it work...

    session = client2.smugmug.login.withPassword({"APIKey": API_KEY, "EmailAddress": sys.argv[1], "Password": sys.argv[2]})

    Thanks David, that works. Shouldn't be too hard to switch our calls from list-of-parameters to dict-of-parameters.
Sign In or Register to comment.