Always, while working on the use case to analyze social media data using Infosphere BigInsights, there is a need to get the facebook data in BigInsights.
Here is the quick code to do that using JAQL :
Here is the quick code to do that using JAQL :
// TODO: Add JAQL content here
// Define the search params
term = "BigInsights";
// Query Facebook for recent public messages about "BigInsights"
results =
read(http("https://graph.facebook.com/search?q=BigInsights &access_token=Access_Token_from_Facebook_developement_page"));
// Get the current system time
time=now();
// Extract selected fields from JSON data returned by social
media site
fbRecords = results[0].data ->
transform {messageID: $.id, user: $.from.name, userID:
$.from.id,
$.message, $.type, $.created_time};
// Write the results of the Jaql query as a delimited file
in HDFS.
// Call dateMillis() function to append unique time to file
name.
// Wrap with serialize() to cast function results as a
string.
fbRecords -> write(del("/user/idcuser/sampleData/"
+
serialize(dateMillis(time)) + ".del",
schema=schema {messageID, user, userID, message, type,
created_time}));
fbRecords;
No comments:
Post a Comment