Xively配置 - 应用如何请求设备Feed ID和密钥?
在"供应"页面上写着: " 8应用程序提示用户输入他们刚刚激活的设备的序列号,应用程序使用主密钥和设备序列号从Xively请求设备Feed ID和密钥。"
这似乎表明有一个API可以做到这一点,但我无法找到它!
是否有人知道文档中的位置或如何执行此操作?
答案 0 :(得分:0)
要获取设备的Feed ID,需要发出Read Device请求。
答案 1 :(得分:0)
2)记下主密钥。现在,要读取为产品(模板)创建的所有设备(实例),请使用来自(1)
的API和密钥此API将返回包含feedId和设备密钥的所有设备。
Curl
的工作示例include ('sensorui.inc');
include(APP_CLASS_LOADER);
// script to list all devices for a product
$url = "https://api.xively.com/v2/products/XwYNEGj4epo7HXNM0DGK/devices" ;
// API KEY
// This is master key API (from Account | settings page)
// for some reason (bug?) READ only key does not work!
$xheaders = array("X-ApiKey" => "your_master_key");
$cookies = array();
$curl = new \com\yuktix\util\curl\Wrapper($url,$cookies,$xheaders) ;
$curl->setCookies($cookies);
$curl->setXHeaders($xheaders);
// $curl->setDebug();
$response = $curl->doGet();
print_r($response);
$code = ($response["code"] != 200) ? 1 : 0 ;
return $code ;
返回
rjha@kubuntu13:~/code/bitbucket/sensorui/scripts/xively$ php list-product.php
Array
(
[code] => 200
[response] => {"totalResults":2,"itemsPerPage":30,"startIndex":1,"devices":[{"serial":"SVSN001","activation_code":"xxx","created_at":"2014-02-02T15:05:37Z","activated_at":"2014-02-02T15:12:41Z","feed_id":xxx,"api_key":"xxx"},{"serial":"SVSN002","activation_code":"xxxx","created_at":"2014-02-02T15:05:37Z","activated_at":null,"feed_id":xxxx}]}