In [26]:
import requests

dweet.io is a simple cloud which could accept data via requests.


In [27]:
payload={'Temperature':'28.1'}

In [28]:
req=requests.get('https://dweet.io/dweet/for/JunTest1?',params=payload)

In [29]:
print(req.content)


b'{"this":"succeeded","by":"dweeting","the":"dweet","with":{"thing":"JunTest1","created":"2017-06-07T06:26:43.658Z","content":{"Temperature":28.1},"transaction":"9847287e-2941-4883-b7ae-466613c2e72d"}}'

Or using dweepy lib


In [30]:
import dweepy

In [31]:
data={'Temperature':'29.1'}

In [32]:
dweepy.dweet_for('JunTest1', data)


Out[32]:
{'content': {'Temperature': 29.1},
 'created': '2017-06-07T06:27:02.576Z',
 'thing': 'JunTest1',
 'transaction': '03afa342-f39b-4c05-a061-c60a7a000215'}

Both ways are ok. And the website to watch data is https://dweet.io/follow/JunTest1


In [41]:
import random
import time

In [42]:
for i in range(100):
    data['Temperature']=random.randint(0,100)
    dweepy.dweet_for('JunTest1',data)
    time.sleep(2)

The following website could fetch data from long term storage of dweet.io


In [44]:
req=requests.get('https://dweet.io/get/dweets/for/JunTest1')

In [45]:
print(req.content)


b'{"this":"succeeded","by":"getting","the":"dweets","with":[{"thing":"JunTest1","created":"2017-06-07T06:36:19.547Z","content":{"Temperature":15}},{"thing":"JunTest1","created":"2017-06-07T06:36:16.633Z","content":{"Temperature":19}},{"thing":"JunTest1","created":"2017-06-07T06:36:13.719Z","content":{"Temperature":26}},{"thing":"JunTest1","created":"2017-06-07T06:36:10.804Z","content":{"Temperature":92}},{"thing":"JunTest1","created":"2017-06-07T06:36:07.892Z","content":{"Temperature":29}}]}'

In [ ]: