First some background!
I have been in the online ringtone business for a few years now. For the largest part of that the ringtone distributor would provide me with lines of javascript that would link to their product database displaying the tones on my pages.
However, I have had to change provider recently and the new provider supplies the tones to me in 2 ways. The first involves putting an iframe on the pages that links to their product database (not very SE friendly). The second involves utilising an xml feed.
The xml option interested me although I have zero expertise in using this. Having looked at the feed it is provided in the following manner:
I contacted the provider to ask how to integrate this into my site using php/mysql (where my knowledge lies) but unfortunately they were only able to suggest an asp solution but were good enough to provide the following asp code to show how the information might be integrated:
Basically the code suggests that it extracts the information from the feed, transforms it into variables and then inserts it into the database (once it is in the DB it is plain sailing!!)
Also. the code needs to change the [siteid[ attribute into my unique user id.
Please, can anyone suggest a similar php solution? I believe that there is a command called DOMDocument that parses the feed but I don’t have a clue where to start using it.
I will be happy to give a credit on the site to anyone who can help me find a solution J.
Thanks for reading.
I have been in the online ringtone business for a few years now. For the largest part of that the ringtone distributor would provide me with lines of javascript that would link to their product database displaying the tones on my pages.
However, I have had to change provider recently and the new provider supplies the tones to me in 2 ways. The first involves putting an iframe on the pages that links to their product database (not very SE friendly). The second involves utilising an xml feed.
The xml option interested me although I have zero expertise in using this. Having looked at the feed it is provided in the following manner:
Code:
<!DOCTYPE prod (View Source for full doctype...)>
- <prod>
- <row>
<prodType>Monophonic</prodType>
<category>African</category>
<code>29165</code>
<prodName>Dil Pardesi Ho Gaya</prodName>
<artist />
<description />
<price />
<provider>Stealthnet</provider>
<providerHomepageUrl />
<previewUrl>[URL unfurl="true"]http://www.customvmail.com/ringtonepreviews2/29165.swf</previewUrl>[/URL]
<listenUrl>[URL unfurl="true"]http://www.axyswebs.co.uk/ringtones/store.asp?code=29165&action=L&siteId={SITEID}</listenUrl>[/URL]
<downloadUrl>[URL unfurl="true"]http://www.axyswebs.co.uk/ringtones/store.asp?code=29165&action=S&siteId={SITEID}</downloadUrl>[/URL]
</row>
etc…..
I contacted the provider to ask how to integrate this into my site using php/mysql (where my knowledge lies) but unfortunately they were only able to suggest an asp solution but were good enough to provide the following asp code to show how the information might be integrated:
Code:
<% Server.ScriptTimeout = 36000 %>
<%
' Desc: Import products of this content provider into the database in regular intervals
' Depn: -
Set httpBinObj = Server.CreateObject("Msxml2.ServerXMLHTTP")
httpBinObj.Open "GET", "[URL unfurl="true"]http://www.axyswebs.co.uk/admin/feed/offer/_axyswebs_sample_feed.xml",[/URL] False
httpBinObj.Send
feedContent = httpBinObj.responseBody
' No XSL but use the XPath language instead
Set theXml = Server.CreateObject("Msxml2.DOMDocument.4.0")
theXml.SetProperty "SelectionLanguage", "XPath"
theXml.SetProperty "NewParser", True
theXmlStatus = theXml.Load(feedContent)
If theXmlStatus <> "True" Then
Response.Write "Error: The feed could not be parsed."
Else
For Each product In theXml.DocumentElement.ChildNodes
For Each column In product.ChildNodes
Select Case column.NodeName
Case "prodType" prodType = column.Text
Case "category" category = column.Text
Case "code" code = column.Text
Case "prodName" prodName = column.Text
Case "artist" artist = column.Text
Case "description" description = column.Text
Case "price" price = column.Text
Case "provider" provider = column.Text
Case "providerHomepageUrl" providerHomepageUrl = column.Text
Case "previewUrl " previewUrl = column.Text
Case "listenUrl " listenUrl = column.Text
Case "downloadUrl " downloadUrl = column.Text
End Select
Next
' Assuming NULL represents an auto-increment primary key
SQL = " INSERT INTO prod VALUES ("
SQL = SQL & " NULL,"
SQL = SQL & " '" & prodType & "',"
SQL = SQL & " '" & category & "',"
SQL = SQL & " '" & code & "',"
SQL = SQL & " '" & prodName & "',"
SQL = SQL & " '" & artist & "',"
SQL = SQL & " '" & description & "',"
SQL = SQL & " '" & price & "',"
SQL = SQL & " '" & provider & "',"
SQL = SQL & " '" & providerHomepageUrl & "',"
SQL = SQL & " '" & previewUrl & "',"
SQL = SQL & " '" & listenUrl & "',"
SQL = SQL & " '" & downloadUrl & "'"
SQL = SQL & ")"
Response.Write "About to insert: " & SQL & "<br><br>"
' Do database inserts here using the SQL string depending on your database setup
Next
End If
%>
Basically the code suggests that it extracts the information from the feed, transforms it into variables and then inserts it into the database (once it is in the DB it is plain sailing!!)
Also. the code needs to change the [siteid[ attribute into my unique user id.
Please, can anyone suggest a similar php solution? I believe that there is a command called DOMDocument that parses the feed but I don’t have a clue where to start using it.
I will be happy to give a credit on the site to anyone who can help me find a solution J.
Thanks for reading.