Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This question already has an answer here:

How do interact with the Twitter API using Mathematica? SocialMediaData is a lovely function, but appears to be severely limited in what it can draw from Twitter. For example, if I want to get a list of retweets of a Tweet I've sent there's an API call for this but not a means of doing so through SocialMediaData. How do I augment the function with all the API has to offer?

share|improve this question

marked as duplicate by Szabolcs, R. M. Sep 12 '13 at 15:44

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

up vote 8 down vote accepted

The Twitter API now requires Oauth 1.0a authentication, so Ragfield's Twitter.m won't work without modification. While I haven't solved the problem for Twitter's API, I have solved two similar authentication problems from Mathematica. You can see what I did here:

Can anyone explain how to use Mathematica's OAuth package?


I just tried it with Twitter and this seemed to work:

token = HTTPClient`OAuthAuthentication[
   "ConsumerKey" -> "your_api_key", 
   "ConsumerSecret" -> "your_api_secret", 
   "RequestEndpoint" -> "",
   "AuthorizeEndpoint" -> "", 
   "AccessEndpoint" -> ""];
url = "";
URLFetch[url, "OAuthAuthentication" -> token]

I don't really know for sure since I don't have any retweets.

share|improve this answer
Very nice. Is there a way to tweak this so that it doesn't request verification through a Twitter account. In particular, If I already know the access token and access token secret, is there a way to pass that in to HTTPClient`OAuthAuthentication? – hailekofi May 3 '13 at 15:33
Yes, here is what I use for fitbit, which will be the same for twitter: HTTPClient`OAuthToken[HTTPClient`OAuth`Private`OAuth10Parameters[ "", None, Automatic, "verifier", Automatic, Automatic, $FitbitConsumerKey, $FitbitConsumerSecret, "", "GET", "", "RemoveWhitespace", "", "GET", "HMAC-Sha1", "HMAC", "oob", "Text/1.0", "Text/1.0", None], HTTPClient`OAuth`Private`Token10[ $FitbitUserKey, $FitbitUserSecret]] – Max May 6 '13 at 2:05
OK... Wow. First, thank you! But how do you know what arguments to feed this function without documentation? – hailekofi May 7 '13 at 3:03
Is there a way to supply the oauth token and receive back not only the json contents but the header as well? Putting URLFetch[url,{"Content","Headers"}, "OAuthAuthentication" -> token] doesn't do the job... – hailekofi Jun 4 '13 at 17:25

Not the answer you're looking for? Browse other questions tagged or ask your own question.