0

誰かが私にJavaの例を見せてもらえますか? 私はそれを探していましたが、何も見つかりませんでした

4

1 に答える 1

0

trackこれは実際には非常に簡単です。POST パラメーターにハッシュ タグを指定する必要があります。

github.com の TwitterClient は、ストリーミング API を使用した Java の例です。いくつかの作業が必要です。最も重要なのは、HttpURL を TwitterClient.java の HttpsURL に変更する必要があることです。

/**
 * Extracts the host and post from the baseurl and constructs an
 * appropriate AuthScope for them for use with HttpClient.
 */
private AuthScope createAuthScope(String baseUrl) throws URIException {
    //HttpURL url = new HttpURL(baseUrl);
    HttpsURL url = new HttpsURL(baseUrl);
    return new AuthScope(url.getHost(), url.getPort());
}

とin に変更http://stream.twitter.com/します。https://stream.twitter.com/example/Example.java

http://github.com/gistinc/TwitterClientコンパイルしたらTwitterClient を取得し、次のように例を実行します。

java <classpathstuff> example.Example username:password -t #YourHashTag

CURL で、このファイルを called で作成しますtrack.txt

track=#YourHashTag

次に、次のようにcurlを実行します...動作していることがわかります:

curl https://stream.twitter.com/1/statuses/filter.json -uusername:password -d @track.txt

お役に立てれば ;-)

于 2011-12-30T19:23:27.093 に答える