Encode URLs for posting help
Encode URLs for posting help
- Subject: Encode URLs for posting help
- From: Neil Lee <email@hidden>
- Date: Wed, 30 Mar 2005 23:53:02 -0500
Hi all -
I'm trying to get over my previous programming knowledge as I learn my
way around Applescript. I'm currently trying to create a script which
will take the currently playing track in iTunes, format it into a HTTP
post-able URL, and send it to a remote PHP script for processing.
I originally repurposed some of the code from Adriaan Tijsseling's
great open source Kung-Tunes script - mainly the code that encoded the
iTunes info - but found it to be very slow and CPU intensive. Then I
hit upon the idea of passing the information to the PHP command line
and using urlencode() to do the heavy lifting.
This is what I ended up using:
on encode_url(this_text)
set this_text to (do shell script "php -r 'echo ¬
urlencode(\"" & this_text & "\");' ")
return this_text
end encode_url
This worked, and is much, much faster and CPU friendly. The issue,
though, is that if any of the track's info has a single or double quote
in it, the script errors out.
I obviously cannot use the addslashes() PHP function to escape the
quotes properly, as you need to pass that to the CLI as a quoted
string, which causes the issue all over again.
Is there a way in Applescript to properly encode the URL for HTTP
posting?
Thanks!
Neil
--
Slumming at the beatnikPad : http://www.beatnikpad.com/
The person you love is 72.8% water.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden