David Ephron
Nov-18-2004, 10:08 AM
I have been experimenting with applescripts to test the xml rpc APIs.
I can get all the methods to work correctly except "upload". I wonder if anyone has had any success?
See the sample script below.
The upload method always gives me an error = 9 code (invalid album id), even though I have inspected the result of the getAlbums method and the albumid appears to be valid (it matches the number in the URL that navigates to the gallery in question through the normal web interface.)
Is it possible that some other problem is incorrectly mapping into this error code, e.g. the upload doesn't like the value of the base64 stream?
Thanks -
DE.
tell application "https://upload.smugmug.com/xmlrpc/"
set returnValue to call xmlrpc {method name:"loginWithPassword", parameters:{"#my e-mail here#", "#my password here#", "1.0"}}
set mySessionID to sessionid of returnValue
end tell
tell application "http://upload.smugmug.com/xmlrpc/"
set returnValue to call xmlrpc {method name:"getAlbums", parameters:{mySessionID}}
set targetAlbumName to "Test" -- this gallery already exists, created manually
set targetAlbumID to -1
repeat with i in returnValue
if the title of i = targetAlbumName then set targetAlbumID to albumid of i
end repeat
-- inspection of returnValue and targetAlbumID shows presence of album "Test" with albumid of 285994
set theCaption to "Caption Sample Text"
set theFileName to "B.jpg"
tell application "Finder" to set encodedStream to read alias "Cookie:Users:dephron:Desktop:Smugmug Upload:Test:B" -- a base64 encoded JPG file
set returnValue to call xmlrpc {method name:"upload", parameters:{mySessionID, targetAlbumID, theCaption, theFileName, encodedStream}}
end tell
I can get all the methods to work correctly except "upload". I wonder if anyone has had any success?
See the sample script below.
The upload method always gives me an error = 9 code (invalid album id), even though I have inspected the result of the getAlbums method and the albumid appears to be valid (it matches the number in the URL that navigates to the gallery in question through the normal web interface.)
Is it possible that some other problem is incorrectly mapping into this error code, e.g. the upload doesn't like the value of the base64 stream?
Thanks -
DE.
tell application "https://upload.smugmug.com/xmlrpc/"
set returnValue to call xmlrpc {method name:"loginWithPassword", parameters:{"#my e-mail here#", "#my password here#", "1.0"}}
set mySessionID to sessionid of returnValue
end tell
tell application "http://upload.smugmug.com/xmlrpc/"
set returnValue to call xmlrpc {method name:"getAlbums", parameters:{mySessionID}}
set targetAlbumName to "Test" -- this gallery already exists, created manually
set targetAlbumID to -1
repeat with i in returnValue
if the title of i = targetAlbumName then set targetAlbumID to albumid of i
end repeat
-- inspection of returnValue and targetAlbumID shows presence of album "Test" with albumid of 285994
set theCaption to "Caption Sample Text"
set theFileName to "B.jpg"
tell application "Finder" to set encodedStream to read alias "Cookie:Users:dephron:Desktop:Smugmug Upload:Test:B" -- a base64 encoded JPG file
set returnValue to call xmlrpc {method name:"upload", parameters:{mySessionID, targetAlbumID, theCaption, theFileName, encodedStream}}
end tell