By the way, it's very easy to use, this is why I named it "EZ".
To read bitcoin price and push to my service, here you can write Python script like this
import time
import urllib
import ezcomet
def read_price():
f = urllib.urlopen('http://data.mtgox.com/api/1/BTCUSD/ticker')
content = f.read()
return content
def main():
api = ezcomet.EZCometAPI(
api_key='<your API goes here>',
user_name='demo',
)
while True:
time.sleep(30)
price_data = read_price()
api.write('bitcoi[Suspicious link removed]ice', price_data)
if __name__ == '__main__':
main()
The javascript to receive messages is also simple
<script src="http://cdn.ezcomet.com/ezcomet.min.js"></script>
<script>
window.onload = function() {
function callback(msg) {
var result = msg['return'].last_local;
var date = new Date( parseInt(msg['return'].now) / 1000 );
// hours part from the timestamp
var hours = date.getHours();
// minutes part from the timestamp
var minutes = date.getMinutes();
// seconds part from the timestamp
var seconds = date.getSeconds();
// will display time in 10:30:23 format
var formattedTime = hours + ':' + minutes + ':' + seconds;
document.getElementById('price').innerHTML = result.display + ' USD';
document.getElementById('now').innerHTML = formattedTime;
}
ezcomet.subscribe({
user_name: 'demo',
channel: 'bitcoi[Suspicious link removed]ice',
msg_type: 'json',
callback: callback,
auto_tick: false
});
};
</script>
You can see the live demo here
http://ezcomet.com/demo/bitcoin_priceIf you have question about my service, you can ask me here.