Last active
December 26, 2015 10:09
-
-
Save tarolandia/7135030 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[taro@tarolandia lib]$ php -a (master ✗) | |
Interactive shell | |
php > include "m2x.php"; | |
php > $m2x = new M2X("b90db94f6ef123c3a291156b7a55e516"); | |
php > $r = $m2x->feeds()->view("8081a7e630caecfb184bdb5f18bad137"); | |
php > print_r($r->json()); | |
stdClass Object | |
( | |
[id] => 8081a7e630caecfb184bdb5f18bad137 | |
[name] => PHP Client Test | |
[description] => | |
[visibility] => private | |
[status] => enabled | |
[type] => blueprint | |
[url] => /feeds/8081a7e630caecfb184bdb5f18bad137 | |
[key] => b90db94f6ef123c3a291156b7a55e516 | |
[location] => stdClass Object | |
( | |
) | |
[streams] => Array | |
( | |
[0] => stdClass Object | |
( | |
[id] => 76 | |
[name] => taro | |
[value] => 50 | |
[min] => 50.0 | |
[max] => 50.0 | |
[unit] => stdClass Object | |
( | |
[label] => Watts | |
[symbol] => W | |
) | |
[url] => /feeds/8081a7e630caecfb184bdb5f18bad137/streams/taro | |
[created] => 2013-10-24T10:47:41Z | |
[updated] => 2013-10-24T10:47:41Z | |
) | |
) | |
[created] => 2013-10-23T20:57:21Z | |
[updated] => 2013-10-23T20:57:21Z | |
) | |
php > $r = $m2x->feeds()->streams("8081a7e630caecfb184bdb5f18bad137"); | |
php > print_r($r->json()); | |
stdClass Object | |
( | |
[streams] => Array | |
( | |
[0] => stdClass Object | |
( | |
[id] => 76 | |
[name] => taro | |
[value] => 50 | |
[min] => 50.0 | |
[max] => 50.0 | |
[unit] => stdClass Object | |
( | |
[label] => Watts | |
[symbol] => W | |
) | |
[url] => /feeds/8081a7e630caecfb184bdb5f18bad137/streams/taro | |
[created] => 2013-10-24T10:47:41Z | |
[updated] => 2013-10-24T10:47:41Z | |
) | |
) | |
) | |
php > $r = $m2x->feeds()->stream("8081a7e630caecfb184bdb5f18bad137", "taro"); | |
php > print_r($r->json()); | |
stdClass Object | |
( | |
[id] => 76 | |
[name] => taro | |
[value] => 50 | |
[min] => 50.0 | |
[max] => 50.0 | |
[unit] => stdClass Object | |
( | |
[label] => Watts | |
[symbol] => W | |
) | |
[url] => /feeds/8081a7e630caecfb184bdb5f18bad137/streams/taro | |
[created] => 2013-10-24T10:47:41Z | |
[updated] => 2013-10-24T10:47:41Z | |
) | |
php > $r = $m2x->feeds()->stream_values("8081a7e630caecfb184bdb5f18bad137", "taro"); | |
php > print_r($r->json()); | |
stdClass Object | |
( | |
[values] => Array | |
( | |
[0] => stdClass Object | |
( | |
[at] => 2013-10-24T10:47:41Z | |
[value] => 50 | |
) | |
) | |
) | |
php > $r = $m2x->feeds()->location("8081a7e630caecfb184bdb5f18bad137"); | |
php > print_r($r->json()); | |
stdClass Object | |
( | |
[name] => Test | |
[latitude] => -23.12333 | |
[longitude] => -60.12312323 | |
[elevation] => 1233 | |
[timestamp] => 2013-10-24T11:14:51Z | |
[waypoints] => Array | |
( | |
[0] => stdClass Object | |
( | |
[name] => Test | |
[latitude] => -23.12333 | |
[longitude] => -60.12312323 | |
[elevation] => 1233 | |
[timestamp] => 2013-10-24T11:14:51Z | |
) | |
) | |
) | |
php > $r = $m2x->feeds()->update_location("8081a7e630caecfb184bdb5f18bad137", array("name" => "new place", "latitude" => "-45.123123", "longitude" => "-70.01233", "elevation" => "400")); | |
php > print_r($r->code()); | |
204 | |
php > $r = $m2x->feeds()->location("8081a7e630caecfb184bdb5f18bad137"); | |
php > print_r($r->json()); | |
stdClass Object | |
( | |
[name] => new place | |
[latitude] => -45.123123 | |
[longitude] => -70.01233 | |
[elevation] => 400 | |
[timestamp] => 2013-10-24T11:19:37Z | |
[waypoints] => Array | |
( | |
[0] => stdClass Object | |
( | |
[name] => new place | |
[latitude] => -45.123123 | |
[longitude] => -70.01233 | |
[elevation] => 400 | |
[timestamp] => 2013-10-24T11:19:37Z | |
) | |
[1] => stdClass Object | |
( | |
[name] => Test | |
[latitude] => -23.12333 | |
[longitude] => -60.12312323 | |
[elevation] => 1233 | |
[timestamp] => 2013-10-24T11:14:51Z | |
) | |
) | |
) | |
php > $r = $m2x->feeds()->update_location("8081a7e630caecfb184bdb5f18bad137", array("name" => "new place", "latitude" => "-35.123123", "longitude" => "-70.01233", "elevation" => "500")); | |
php > $r = $m2x->feeds()->location("8081a7e630caecfb184bdb5f18bad137"); | |
php > print_r($r->json()); | |
stdClass Object | |
( | |
[name] => new place | |
[latitude] => -35.123123 | |
[longitude] => -70.01233 | |
[elevation] => 500 | |
[timestamp] => 2013-10-24T11:21:25Z | |
[waypoints] => Array | |
( | |
[0] => stdClass Object | |
( | |
[name] => new place | |
[latitude] => -35.123123 | |
[longitude] => -70.01233 | |
[elevation] => 500 | |
[timestamp] => 2013-10-24T11:21:25Z | |
) | |
[1] => stdClass Object | |
( | |
[name] => new place | |
[latitude] => -45.123123 | |
[longitude] => -70.01233 | |
[elevation] => 400 | |
[timestamp] => 2013-10-24T11:19:37Z | |
) | |
[2] => stdClass Object | |
( | |
[name] => Test | |
[latitude] => -23.12333 | |
[longitude] => -60.12312323 | |
[elevation] => 1233 | |
[timestamp] => 2013-10-24T11:14:51Z | |
) | |
) | |
) | |
// USING METHOD 1 (POST) | |
php > $r = $m2x->feeds()->add_stream_values("8081a7e630caecfb184bdb5f18bad137", "taro", array(array("value" => "10"), array("value" => "5"))); | |
php > print_r($r->json()); | |
php > $r = $m2x->feeds()->stream_values("8081a7e630caecfb184bdb5f18bad137", "taro"); | |
php > print_r($r->json()); | |
stdClass Object | |
( | |
[values] => Array | |
( | |
[0] => stdClass Object | |
( | |
[at] => 2013-10-24T12:03:40Z | |
[value] => 5 | |
) | |
[1] => stdClass Object | |
( | |
[at] => 2013-10-24T12:03:40Z | |
[value] => 10 | |
) | |
[2] => stdClass Object | |
( | |
[at] => 2013-10-24T11:48:30Z | |
[value] => 200 | |
) | |
[3] => stdClass Object | |
( | |
[at] => 2013-10-24T11:48:11Z | |
[value] => 60 | |
) | |
[4] => stdClass Object | |
( | |
[at] => 2013-10-24T11:42:15Z | |
[value] => 60 | |
) | |
[5] => stdClass Object | |
( | |
[at] => 2013-10-24T11:37:28Z | |
[value] => | |
) | |
[6] => stdClass Object | |
( | |
[at] => 2013-10-24T11:36:29Z | |
[value] => | |
) | |
[7] => stdClass Object | |
( | |
[at] => 2013-10-24T10:47:41Z | |
[value] => 50 | |
) | |
) | |
) | |
//USING Method 2(PUT) | |
php > $r = $m2x->feeds()->update_stream("8081a7e630caecfb184bdb5f18bad137", "taro", array("value" => "1")); | |
php > $r = $m2x->feeds()->stream_values("8081a7e630caecfb184bdb5f18bad137", "taro"); | |
php > print_r($r->json()); | |
stdClass Object | |
( | |
[values] => Array | |
( | |
[0] => stdClass Object | |
( | |
[at] => 2013-10-24T12:07:56Z | |
[value] => 1 | |
) | |
[1] => stdClass Object | |
( | |
[at] => 2013-10-24T12:03:40Z | |
[value] => 5 | |
) | |
[2] => stdClass Object | |
( | |
[at] => 2013-10-24T12:03:40Z | |
[value] => 10 | |
) | |
[3] => stdClass Object | |
( | |
[at] => 2013-10-24T11:48:30Z | |
[value] => 200 | |
) | |
[4] => stdClass Object | |
( | |
[at] => 2013-10-24T11:48:11Z | |
[value] => 60 | |
) | |
[5] => stdClass Object | |
( | |
[at] => 2013-10-24T11:42:15Z | |
[value] => 60 | |
) | |
[6] => stdClass Object | |
( | |
[at] => 2013-10-24T11:37:28Z | |
[value] => | |
) | |
[7] => stdClass Object | |
( | |
[at] => 2013-10-24T11:36:29Z | |
[value] => | |
) | |
[8] => stdClass Object | |
( | |
[at] => 2013-10-24T10:47:41Z | |
[value] => 50 | |
) | |
) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment