Group Abstract Group Abstract

Message Boards Message Boards

[Mathematica-vs-R] Text analysis of Trump tweets

Posted 9 years ago
POSTED BY: Anton Antonov
5 Replies

Even if source parameter is not supported, you can quickly create you own utility to get what you want, e.g.

In[1]:= twitter = ServiceConnect["Twitter", "New"]
Out[1]= ServiceObject["Twitter", 
 "ID" -> "connection-29f751249df0b3e87a365f8c21a6b31f"]

In[20]:= url = 
  "https://api.twitter.com/1.1/statuses/user_timeline.json";

In[21]:= userid = Lookup[First@twitter["UserData"], "ID"];

(*build url with required paramaters*)
In[30]:= urlstring = 
  URLBuild[{url}, {"user_id" -> ToString@userid, 
    "screen_name" -> "realDonaldTrump", "count" -> 5}];

(*fetch data using authentication framework*)
In[31]:= result = OAuthClient`oauthdata[twitter, urlstring];

(*post processing result*)
In[33]:= data = ImportString[result[[2]], "RawJSON"];

In[34]:= #["source"] & /@ data
Out[34]= {
"<a href=\"http://twitter.com/download/iphone\" \rel=\"nofollow\">Twitter for iPhone</a>",
"<a href=\"http://twitter.com/download/iphone\" rel=\"nofollow\">Twitter \for iPhone</a>",
"<a href=\"http://twitter.com/download/iphone\" rel=\"nofollow\">Twitter for iPhone</a>",
"<a href=\"http://twitter.com/download/iphone\" rel=\"nofollow\">Twitter \for iPhone</a>",
"<a href=\"http://twitter.com/download/iphone\" rel=\"nofollow\">Twitter for iPhone</a>"
}
POSTED BY: Damanjit Singh
POSTED BY: Anton Antonov
POSTED BY: EDITORIAL BOARD
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard