|
|
Thread Tools | Display Modes |
|
#1
|
|
|
Beginner grinner
|
Trying to use upload method through applescript
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 set returnValue to call xmlrpc {method name:"upload", parameters:{mySessionID, targetAlbumID, theCaption, theFileName, encodedStream}} end tell |
|
|
|
|
#2
|
||
|
SmugMug CEO & Chief Geek
|
Quote:
Is there any particular reason you're not using the HTTP POST w/XML-RPC reply method? That method has been tested more and is currently in use by a few applications, so we're positive it works. The base64 upload worked the last time I used it, but it's possible something has changed since then. Do you have a way to capture exactly what XML-RPC data you're sending me? I could dissect it and take a look... Don |
|
|
|
||
|
#3
|
||
|
SmugMug CEO & Chief Geek
|
Quote:
You're sending your base64 JPG as a String, but in reality, it needs to be a base64 scalar. If you change your XML tag to say <base64> rather than <string> you should be all set. Let me know if that doesn't clear it up. Don |
|
|
|
||
|
#4
|
||
|
Beginner grinner
|
Quote:
The instructions at http://www.smugmug.com/hack/xmlrpc-post are not clear at all to someone who hasn't written these kinds of applications before. Perhaps you could post an example of how to upload a single file with a specified pathname, albumid, and caption using applescript or from the MacOS X command line or as HTML file that can be invoked by opening in a web browser or some other easily accessible method? Thanks - DE. |
|
|
|
||
| Tell The World! | |
| Thread Tools | |
| Display Modes | |
|
|