i'm triyng to upload some data to xively from ruby, i did install all the gems and this test code runs ok, but nothing changes in the xively graph of my device.
This small code was isolated from the fragment of a bigger code that works fine, and post data to my server with an interface written in php, but now i want to use xively to log the data.
I did remove my personal data from this code, API_KEY, Feed number and feed Name.
#!/usr/bin/ruby
require 'rubygems'
require 'json'
require 'xively-rb'
##Creating the xively client instance
API_KEY = "MY_API_KEY_WAS_HERE"
client = Xively::Client.new(API_KEY)
#on an endless loop
while true
#n is a random float between 0 y 1
n = rand()
##Creating datapoint and sendig it to xively
puts "Creating datapoint "+Time.now.to_s+", "+n.to_s+" and sending it to xively"
datapoint = Xively::Datapoint.new(:at => Time.now, :value => n)
client.post('/api/v2/feeds/[number]/datastreams/[name]', :body => {:datapoints => [datapoint]}.to_json)
end
it would be nice to get an example on how to use that library, i didn't find any concise example.
(It's possible to find some silly errors in the code, if it's so, it's ok because im learning ruby at the moment, if it isn't critical just point it out briefly to not go offtopic, i will be happy to research and learn later)
im really looking forward for some answer, so thanks in advance.
I receive a solution that works from a classmate, it was in a post about Cosm the beta of what now is xively, what previously was pachube also.
we were about two weeks looking for something like this:
afulki.net more-on-ruby-and-cosm
Using that class: