Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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, rm -rf 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.

1 Answer 1

up vote 6 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?

UPDATE:

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

token = HTTPClient`OAuthAuthentication[
   "ConsumerKey" -> "your_api_key", 
   "ConsumerSecret" -> "your_api_secret", 
   "RequestEndpoint" -> "https://api.twitter.com/oauth/request_token",
   "AuthorizeEndpoint" -> "https://api.twitter.com/oauth/authorize", 
   "AccessEndpoint" -> "https://api.twitter.com/oauth/access_token"];
url = "https://api.twitter.com/1.1/statuses/retweets_of_me.json";
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[ "api.fitbit.com", None, Automatic, "verifier", Automatic, Automatic, $FitbitConsumerKey, $FitbitConsumerSecret, "https://api.fitbit.com/oauth/request_token", "GET", "https://www.fitbit.com/oauth/authorize", "RemoveWhitespace", "https://api.fitbit.com/oauth/access_token", "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.