Quote:
Originally Posted by astronaut x
First of all, I would like to say thanks for an actual business thread.
Ive been wanting to use the chaturbate API to build out a couple of unused domains, but I haven't been able to locate the correct information on how to accomplish that. They say you need a programmer, but I have some programming experience so I was hoping to do it myself. Id like to know how to get the XML API feed to load into a database and pull some of that information to display but so far I haven't come up with anything. Any idea of where to begin?
|
Well it is easy, in theory at least
1- create a table in MySQL to store perfomers data
2- Python script to load and parse the XML tree (JSON is easier) and save into mysql.
3- a cron job scheduled every minute that runs the above script
4- truncate the table every time to make sure the data is fresh
Python is widely supported and super powerful (it takes a few lines of code to achieve what you want)
Code:
import urllib2
insert_sql_statement = 'INSET INTO ...'
broadcasters = urllib2.urlopen(chaturbate_api_json_url)
try:
cur.executemany(insert_sql_statement, broadcasters)
except Exception:
logging.error('oops')
This assume you have an SQL statement that works (try it manually). cur is a MySQLdb cursor (plenty of code samples in google/stackoverflow)
It is very simplistic but it is a functional kick off snippet. It is worth spending some time doing this because you can then reuse this module to import data from everywhere.
Then there is the display part. You can use a php foreach loop. One solutions out of many.