Javascript solution?

B

bruce2005

Hi,

I'm new here, been lurking and trying to learn more. I was wondering
something. I have a client who does text to mp3 changes. The app reads
the text on the webpage and returns an mp3 of it.

So basically the url we have to work with is:
To get the mp3:
http://www.talkr.com/app/get_mp3.app?feed_url=http://www.somedomain.xml&
permalink=http://www.somedomain/articlename.php&url_only=
I can get the mp3 filename into an mp3 player on a page using curl and
php, but we need a javascript solution so more can use it on their
sites.
To extract the mp3 (its like a redirect?) and put it in the filename
in mp3 player on a webpage...

Can this be done in javascript?
 
D

David Mark

Hi,

I'm new here, been lurking and trying to learn more. I was wondering
something. I have a client who does text to mp3 changes. The app reads
the text on the webpage and returns an mp3 of it.

So basically the url we have to work with is:
To get the mp3:http://www.talkr.com/app/get_mp3.app?feed_url=http://www.somedomain.xml&
permalink=http://www.somedomain/articlename.php&url_only=
I can get the mp3 filename into an mp3 player on a page using curl and
php, but we need a javascript solution so more can use it on their
sites.
To extract the mp3 (its like a redirect?) and put it in the filename
in mp3 player on a webpage...

Can this be done in javascript?

Yes. Your client's Webmaster customers would sdd a script block to
their pages that references a PHP script on your server, passing
parameters that identify the page, client ID, etc. Your server-side
script would send back JS that creates a couple of nested object tags
to reference the appropriate MP3 on your server.

Assuming your client isn't going to dictate MIME types to their
customers, you will need a script that can handle both HTML and
XHTML. The simplest way to do that is to design it without
document.write and innerHTML. Use DOM methods (eg createElement,
createElementNS, appendChild, etc.) to create and add the object tags
and you won't have to write two radically different solutions.

And when your server script retrieves pages that do not vary their
content (eg do not change MIME types), you can send a flag to the
client script to tell it which method to use. The reason I would do
this is that client-side detection requires page authors to follow
standards (and you clearly can't control that.) The same could be
said for server-side detection, but I would think that Webmasters who
employ content negotiation on their server would indicate that in
their responses (eg with a Vary header.) Neither method is foolproof,
but fixing server problems is easier than fixing every page on a site.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,159
Messages
2,570,879
Members
47,416
Latest member
LionelQ387

Latest Threads

Top