Sending base64 image data using xmlrpc

I’m trying to send images to a wordpress blog using xmlrpc using the script below. The images aren’t getting decoded by wordpress and I’m reasonably certain that this can be fixed by wrapping the base64 encoded data in tags. My problem, though, is that xmlrpc seems to be encoding the tag’s angle brackets to >/< tokens. Does anyone have any idea how I can prevent this.


use framework "Foundation"
use scripting additions

set filePath to "/Users/kimaldis/Desktop/t.jpg"
set base64 to do shell script "openssl base64 -in " & quoted form of POSIX path of filePath

tell application ""
	set params to {1, "admin", "admin", {|name|:"_DSC3996.jpg", bits:"<base64>" & base64 & "<base64>", gallery:8, overwrite:1}}
	set gals to call xmlrpc {method name:"ngg.uploadImage", parameters:params}
end tell

Further investigation, for clarity, using a packet sniffer and comparing packets between the Applescript and a PHP script that works. The php script sends this:

bitsencoded image data

where the Applescript sends this:

bits [i]encoded image data[/i]

My guess would be something like this:

   set params to {1, "admin", "admin", {|name|:"_DSC3996.jpg", bits:{base64:base64text}, gallery:8, overwrite:1}}

There is no support for base64 XMLRPC tag in AppleScript because base64 is a later addition to XMLRPC. Apple only support the pre-1999 XMLRPC specification. Instead you can use PHP’s XMLRPC and base64 support on the command line using a do shell script (or change the wordpress script).

Nice try, Shane, but it looks like DJ is right. Your solution sends:

base64image data

php it is, I guess.

thanks for the input all.