This file contains 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
String csdl = "tag.brand \"Calvin Klein\" { interaction.content contains \"Calvin Klein\" } " + | |
"tag.brand \"GQ\" { interaction.content contains \"GQ\" } " + | |
"tag.brand \"Adidas\" { interaction.content contains \"Adidas\" } " + | |
"return { " + | |
"interaction.content contains_any \"Calvin Klein, GQ, Adidas\" " + | |
"}"; |
This file contains 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
// Subscription handler | |
public static class Subscription extends StreamSubscription { | |
public Subscription(Stream stream) { | |
super(stream); | |
} | |
public void onDataSiftLogMessage(DataSiftMessage di) { | |
System.out.println((di.isError() ? "Error" : di.isInfo() ? "Info" : "Warning") + ":\n" + di); | |
} |
This file contains 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
datasift.liveStream().onError(new ErrorHandler()); // handles stream errors | |
datasift.liveStream().onStreamEvent(new DeleteHandler()); // handles data deletes | |
// Subscribe to the stream | |
datasift.liveStream().subscribe(new Subscription(stream)); |
This file contains 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
try { | |
// Compile filter looking for mentions of brands | |
String csdl = "interaction.content contains_any \"Calvin Klein, GQ, Adidas\""; | |
Stream stream = datasift.compile(csdl).sync(); | |
} | |
catch(Exception ex) | |
{ | |
// TODO: Your exception handling here |
This file contains 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
public static void main(String[] args) { | |
// TODO: Enter your username and API key | |
DataSiftConfig config = new DataSiftConfig("YOUR_USERNAME", "YOUR_APIKEY"); | |
DataSiftClient datasift = new DataSiftClient(config); | |
} |
This file contains 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
<dependencies> | |
<dependency> | |
<groupId>com.datasift.client</groupId> | |
<artifactId>datasift-java</artifactId> | |
<version>3.x.x</version> | |
</dependency> | |
</dependencies> |
This file contains 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
import com.datasift.client.DataSiftClient; | |
import com.datasift.client.DataSiftConfig; | |
import com.datasift.client.core.Stream; | |
import com.datasift.client.stream.*; |
This file contains 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
Console.WriteLine("{0}: {1}", message.interaction.tag_tree.brand[0], message.interaction.content); |
This file contains 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
var csdl = @"tag.brand ""Calvin Klein"" { interaction.content contains ""Calvin Klein"" } | |
tag.brand ""GQ"" { interaction.content contains ""GQ"" } | |
tag.brand ""Adidas"" { interaction.content contains ""Adidas"" } | |
return | |
{ | |
interaction.content contains_any ""Calvin Klein, GQ, Adidas"" | |
}"; |
This file contains 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
static void stream_OnConnect() | |
{ | |
Console.WriteLine("Connected to DataSift."); | |
// Subscribe to stream | |
_stream.Subscribe(_hash); | |
} | |
static void stream_OnMessage(string hash, dynamic message) | |
{ |