Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
434 lines (352 sloc) 15.3 KB

Online Key Value Service and eMail relay

Key value Online Service:

Key JSON Online service

Key FILE Online service

Key QUEUE Online service

Key EMAIL Online service

store a value online http: // and get it back later https: //meeiot/get...



Use your own named 'keys' with meaning. (only letters, numbers and underscores)

There is a free token in these demos to mess with. The free token has restricted 
credential and response time of 4 seconds. There are 4 types of tokens accounts. 

    - 0 is the free token, and has ben generated for demo purpose. A token for account type 
        1 is generated on social logins. This token have a wide range of access for a decent 
        rig of devices. 
    - 1 social login, has the response time 1 second. Email relay is working with 
        Google social login token, because is the only social login which provie us with 
        your email. 
    - 2 paid token, with extended capabilities. 
    - 3 dedicated server, custom payloads
Once you have been authenticated either social login or PayPal you will have a token. 
The token is shown in the status bar. You dont have to stay logged in once you have the token.
Save it in a file so you can use it from anywhere, anytime. If you log in with different 
social logins you can have 3 different tokens, but there is no need, because
on a token you can have create many keys.
The number of active keys per token depends by the account you have. 
If you relog at later date with same social credentials the initial token would be handed back.
On each token you can have at any time 

    - Account 1 (social login)  maximum 16 keys and maximum 32 items in queue.    
    - Account 2 (19$)           maximum 64 keys and maximum 36000 items in queue. 
    - Account 3                 custom.
- A key which has not been updated for 2 days, except mail reminders is deleted.
- A queue push can overflow the queue if pop has not been called for long time. When
  the queue overflows, oldest value is deleted.
- Social login credentials can be deleted using the token generated with. 

alt text


2018 June 4       https://meeiot/act/TOKEN          Activity report on token, last 400 entries.
    check the free token:

API's      stores a value under a key      get's a value from a key, updates last access time     push a value to the head of the key queue. (keep adding)      pops (removes) a value from the tail of the key queue. updates last access time      deletes the key / or a value for a key      Deletes the account associated to token. TOKEN remains active, but the account
                            and all user information associated with the TOKEN is deleted.
                                 all the keys and values for token         just the key and it's val                     deletes all the queue(s) or one queue           all the queues       just the queue  {HTTP_POST JSON}          {from: to: subject: message:}    sends an email/ or callback mail reminder    


Test User token: $TOKEN
    Operations using demo user id has a delay of 4 secoonds.
    Mail service is disabled for test token
    see the extra hdr="headers,..." attribute
    If HTTP_POST has the 'hdr' field  hdr="HTTP_HEADERS,COMMA,SEPARATED", then when the value
    id taken back, proper http headers are send before the value.
# This is a demo token and has restricted access. Many users can mess with.
curl$TOKEN/myq=1  # puts 1 in q
curl$TOKEN/myq=1  # puts 1 again in q
curl$TOKEN/myq=3  # puts 3 in q

curl$TOKEN         # lists the que items
curl$TOKEN/2       # lists the que items at index 2 which is 3 (index starts with 0)
# pops items from queue tail
curl$TOKEN/myq     # returns 1 (tail of the queue, pop's (deletes))
curl$TOKEN/myq     # returns 1
curl$TOKEN/myq     # returns 3 # now queue is emmpy

# stores a json at key myjson
curl -H "Content-Type: application/json" -X POST -d '{"value":"xyz"}'$TOKEN/myjson

# stores a json from a file at key myjson
curl -v -H "Content-Type: application/json" -X POST -d @./json.txt$TOKEN/myjson

# stores a json at key jsonweb and sends it back (get) with HTTP headers 'Content-Type: application/json'
curl  -F jsonweb=@./json.txt -F hdr="Content-Type: application/json"$TOKEN

# stores an image from a file at key imageweb and get's ig back with proper HTTP image headers
curl  -F imageweb=@./meeiot.jpg -F hdr="Content-Type: image/jpeg"$TOKEN

# The image is shown properly in a browser.$TOKEN/imageweb

# File http multpart is denied for demo token, but this would store a file at key mykey
curl -F mykey=@testfile$TOKEN

# Mail relay is denied for demo token, but this would send an email to JSON:to field
curl -H "Content-Type: application/json" -X POST -d @./mail.json$TOKEN

# mail json format
    "from":"SENDER EMAIL",  // reply to
    "to":"RECEIVER EMAIL",
    "subject":"test mail meeiot org",
    "message": " an email containing some crap"
# mail is sent from '' (check trash box)    

# Reminder. Sends back to your registered email at specified date. Needs a key for the reminder
# In case you want to delete the reminder use the key 

curl -k  -H "Content-Type: application/json" -X POST -d @./mail.json$TOKEN/birthday
# III  this might not work with community-singin other then Google 
# to keep your privacy to maximum. This would work with PayPal paid tokens only.
# If there is no email in the token's account the API returns an error
    "subject":"wife birthday",
    "message": "gotta get this right!"

#To list your reminders, one per line as: when | key for reminder email | recipient to
2018-10-20 12:37:00|myemail2|,

#To list the reminder content as: when|content| recipient to
curl$TOKEN/birthday   # birthday is the mail key
2018-10-20 12:37:00|{exact json content}|,

#To delete  a reminder send an empty json on the reminder  key
curl -k -H "Content-Type: application/json" -X POST -d '{}'$TOKEN/birthday


0:X     success:scheme used
1:*     user id missing
2:*     value missing
4:*     empty json post
5:*     key  too big or to small
6:*     value too big for the account, or empty
7:*     json too big for the account, or empty
8:*     multipart attachment FILE to big for this type of account
9:*     user id mismatch
10:*    user key mismatch. Error++, on 3 errors IP is banned.
11:*    access time to early since last access
12:*    access time error. could not determine last access time.
13:*    delete operation not allowed from other then put/push ip (demo id only)
14:*    client ip retrieval fail
20:*    system error
30:*    database err
31:*    database err
60:*    database err
61:*    database err
99:*    invalid request
111:*   no more data for the key
#mail errors
40:*    to email malformated    
41:*    from email malformated
42:*    subject to long 128 characters.
66:*    access denied for service


$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"$TOKEN/mydata");
curl_setopt($ch, CURLOPT_POST, 1);
$payload = json_encode( array( "jsonkey"=> "json value" ) );
curl_setopt( $ch, CURLOPT_POSTFIELDS, $payload );
curl_setopt( $ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json'));
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
$result = curl_exec($ch);
echo "$result";

// or just inline using GET




// share data
EthernetClient client;
if (client.connect(server, 80)) 
    char req[200];
    sprintf(req,"GET /put/5ba8e5788973226b3255844b37221c2a0f8a3921784b8cf1c93b9f/mysensor=$d HTTP/1.1", sensorvalue);
    client.println("Connection: close");
    while (!client.available()) {delay(1000);}
    char c =;


p=`ping -c 1 2>&1 | grep "0% packet loss"`
[[ -z ${p} ]] && exit
[[ ! -f ${JSON_TO_SHARE} ]] && exit
curl -vX POST${NYID}/mydata -d @${JSON_TO_SHARE}  --header "Content-Type: application/json"


# cron script with liveimage timelapse or motion detection image sharing trough meeiot.
p=`ping -c 1 2>&1 | grep "0% packet loss"`
[[ -z ${p} ]] && exit
TOKEN="$TOKEN" ## need a paid account to allow over 16k POST's
pushd /data/snaps
image=$(ls -rt | tail --lines=1)
if [[ ! -z $lastfile ]];then
        curl -k -F img=@$image


echo "Test with free user token. Delay between put's/gets $delay seconds. Adding some values"
curl -k${token}/value=xxxxxxxx
sleep $delay
curl  -k${token}/value1=somevalue
sleep $delay
curl  -k${token}/value2=zzzzzzzzzzzzz
sleep $delay
echo "getting all keys"
sleep $delay

curl -k${token}
echo ""
echo "getting all values"
sleep $delay
curl -k${token}/value
echo ""
sleep $delay
curl -k${token}/value1
echo ""
sleep $delay
curl -k${token}/value2
echo " deleting all keys"
sleep $delay
curl -k${token}
echo "getting all keys"
sleep $delay
curl -k${token}

sleep $delay

echo "sending a text file as multipart"
curl  -k -F file1=@testfile${token}
sleep $delay
echo "getting all keys"
echo ""
sleep $delay
curl -k${token}
echo ""
echo "getting file"
sleep $delay
curl  -k${token}/file1
echo ""

echo "put an image as raw then with headers"
sleep $delay
curl  -F imageweb=@./meeiot.jpg -F hdr="Content-Type: image/jpeg"${token}
sleep $delay
curl   -F image=@./meeiot.jpg${token}
echo "get  image as raw"
echo "open the link in the browser:. See headers for content type are OK"
echo "${token}/image"
read dummy
echo "get  image as web with http headers. open thislink in browser. then press a key to continue"
sleep $delay
read dummy

echo "push an image as raw then with headers"
sleep $delay
curl  -F imageweb=@./meeiot.jpg -F hdr="Content-Type: image/jpeg"${token}
sleep $delay
curl   -F image=@./meeiot.jpg${token}
echo "get  image as raw. open link in browser"
echo "${token}/image"
read dummy

echo "get  image as web with http headers. open thislink in browser. then press a key to continue"
sleep $delay
read dummy

echo "put a jsonraw to [jsonraw] = {...} and get it back raw "
sleep $delay
curl -H "Content-Type: application/json" -X POST -d '{"value":"xyz"}'${token}/jsonraw
echo "keys for user"
sleep $delay
echo "getting back json"

echo "put a json and get it back with HTTP headers application/json "
sleep $delay
curl  -F jsonweb=@./json.txt -F hdr="Content-Type: application/json"${token}
echo "open the link in the browser:. See headers for content type are OK"
read dummy;

shell sample using curl to check keys and queues storage

the user token was shorten as well for readability

# add some keys
shell:~$ curl$TOKEN/key1=value1
shell:~$ curl$TOKEN/key2=value2
# make some queues
shell:~$ curl$TOKEN/q1=value 
shell:~$ curl$TOKEN/q1=value2
shell:~$ curl$TOKEN/q1=value3
shell:~$ curl$TOKEN/q2=value1

#list my keys
shell:~$ curl$TOKEN          

#list my keys as links in browser
shell:~$ curl$TOKEN/?
<pre><a href='$TOKEN/key1'>$TOKEN/key1</a>
<a href='$TOKEN/key2'>$TOKEN/key2</a><pre>

#list my keys as url
shell:~$ curl$TOKEN/*$TOKEN/key1$TOKEN/key2shell:~$ 

#list my queues and the number of items in each que
shell:~$ curl$TOKEN

#list queus as web links
shell:~$ curl$TOKEN/?
<pre><a href='$TOKEN/q1/0'>$TOKEN/q1/0</a>
<a href='$TOKEN/q1/1'>$TOKEN/q1/1</a>
<a href='$TOKEN/q1/2'>$TOKEN/q1/2</a>
<a href='$TOKEN/q2/0'>$TOKEN/q2/0</a></pre>

#list as url's
shell:~$ curl$TOKEN/*$TOKEN/q1/0$TOKEN/q1/1$TOKEN/q1/2

#offline now!

BeagleBone GPIO LED's online demo:

(allow 6..7 seconds for LED's to update)

Check README2 too