java - 在 Eclipse 中获取 Xively 数据流

标签 java eclipse xively

我正在尝试使用 Xively4J 从 Xively 获取数据流。我已经下载了snapshot jar from Sonatype repo 。我认为有一个 getDatastreams() 方法,但这个方法很奇怪,因为它不接受参数。如何使用此方法从特定 Xively 源获取我想要的数据流?有人可以给我一个使用这种方法的例子吗?

最佳答案

下面的代码片段列出了您的特定 Feed 的 channel 名称:

import java.util.Collection;
import java.util.Iterator;

import com.xively.client.XivelyService;
import com.xively.client.model.Datastream;
import com.xively.client.model.Feed;


public class MainClass {

    public static void main(String[] args) {
        Feed feed = XivelyService.instance().feed().get(6630948);  //your feedID as argument

        System.out.println("channels of feed "+feed.getId()+ ":");

        Collection<Datastream> datastreams = feed.getDatastreams();
        Iterator<Datastream> datastreamsIterator=datastreams.iterator();

        while(datastreamsIterator.hasNext()){           
            Datastream currentDatastream=datastreamsIterator.next();    
            System.out.println(currentDatastream.getId());
        }


    }//end main

}//end class

确保您已在文件 src/main/res/config.properties 中添加 API key 没有任何引号的图书馆。例如:

# The key used for authenticating API calls.
api.key=rtBB60ref6TRi23yQeWMfI0034DRDsYdd4lbJjRZoFLQI00

关于java - 在 Eclipse 中获取 Xively 数据流,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19093684/

相关文章:

android - 在两个android Activity 中实现相同的音乐

c++ - 如何更新 C++ 项目中的 xively 提要

java - 编辑xml文件java

Eclipse 终端不更新/行为奇怪

java - 道。多对多关系

java - 如何将所有包名称重命名为小写

Python 捕获超时并重复请求

javascript - Xively 使用 javascript 从 feed 获取数据流列表

JAVA-Apache BEAM-GCP : GroupByKey works fine with Direct Runner but fails with Dataflow runner

java - 如何获取 5x5 正方形的 RGB 值?