Recently my main client decided that he wanted to promote live webcams utilizing Streamate’s excellent affiliate program tools. However, with this particular client things are never as easy as using the simplest tools – no he needed to pull highly niched keywords and that meant I couldn’t use a simple iframe – I would have to utilize a custom XML feed. I have never worked with XML data before, so I wasn’t quite sure what to expect. Turns out that it wasn’t so bad, but a brief tutorial would have really helped.
THE PROCESS
You need to send what Streamate calls a “SMLive AvailablePerformers Query”. This query is used to retrieve information about Streamate’s performers. It allows for real-time feeds of live performers, nickname searches, keyword searches, attribute searches, and more. It also provides access to almost all information available for each performer such as their attributes, descriptions, photo galleries, etc. You will receive this information packaged into an XML document. You send your XML request by HTTP POST to: http://affiliate.streamate.com/SMLive/SMLResult.xml. Once you get the XML document back from Streamate you need to parse it and format it. Sound easy? I thought so too, but I struggled a little to get it working.
SENDING THE POST REQUEST
After fiddling with some other options I decided to use cURL to send my POST request. The main reason I chose cURL was that I was familiar with it having used it in the past for other projects. I am sure there are better ways of doing it, but this worked for me. Here is what my request looked like:
Basically it’s just indicating the information you want returned to you in an XML request, declaring some variables, and setting the cURL options. We finish the request by storing the returned results in a variable I have called $result, and then closing our cURL instance. I then use SimpleXML to load the returned information as a string into the variable $xml. This is the variable I will use later to help return the information I want to display on my web page. This worked great for me. Your mileage may vary. If you want more information about cURL, its usage and options check here: http://php.net/manual/en/book.curl.php
THE DATA YOU GET BACK
Here is a sample of the data the above request would return:

Keep in mind that the data you get back is dependent on the request you sent earlier, so yours may look a bit different if you requested your own keywords, etc.
WHAT TO DO WITH THE DATA ONCE YOU GET IT
Now all that’s left to do is grab the information you want displayed on your web page, format it, and spit it out! The whole process looked like this for me:

This is actually MUCH easier to show visually I think, so here’s a video. Hope it helps
So there you have it. I hope this tutorial helped you out. Feel free to leave comments or ask questions either in the comments or in my “Questions” section.
Here is a link to the gist containing my source: https://gist.github.com/1702147
Since someone asked, here is the complete list of XML attributes you can request from Streamate: https://gist.github.com/1707415
I have also added simple pagination to the script, along with a slight refactoring: https://gist.github.com/1720021. A full tutorial on this is coming soon