Code covered by the BSD License  

Highlights from
twitty

5.0

5.0 | 1 rating Rate this file 25 Downloads (last 30 days) File Size: 13.27 KB File ID: #34837
image thumbnail

twitty

by Vladimir Bondarenko

 

30 Jan 2012 (Updated 26 Apr 2012)

Interface-class to the Twitter REST API.

| Watch this File

File Information
Description

twitty is a MATLAB class for interaction with the twitter platform via its REST API.
Here are some examples of its usage:
tw = twitty(credentials); % create a twitty object and supply user credentials.
The credentials argument is a structure with the user account's credentials.
The fields are: .ConsumerKey, .ConsumerSecret, .AccessToken, .AccessTokenSecret. E.g.,
credentials.ConsumerKey = 'WuhMKJJXx0TzEtu435OXVA'
credentials.ConsumerSecret = '5ezt6zOG6dDWLZNzxUHsKJtUs52kmMtDqzV7nEjnhU'
credentials.AccessToken = '188321184-7iVtMvx3JVhwfdvJf5J2NKiuQzTz47UnQsFJnWlG'
credentials.AccessTokenSecret = 'idev6Hmq68EsVIQb3pP8nSeN9Rt629BJ4yPKlqlwZk'.

For details on OBTAINING TWITTER CREDENTIALS, type "help twitty" and read the corresponding section.

After setting the credentials, you should be able to access your twitter account from MATLAB. E.g.:

1. S = tw.search('matlab'); % search twitter.com for messages including the word 'matlab'.
2. S = tw.updateStatus('Hello, Twitter!'); % or twit something cooler.
3. S = tw.publicTimeline(); % get 20 recent public messages.
4. S = tw.userTimeline('screen_name', 'matlab'); % get recent messages posted by the user 'matlab';
5. S = tw.trendsDaily(datestr(now-1,'yyyy-mm-dd')); % get yesterday's trends.

Conceptually, twitty is just a collection of wrapper functions around the main function that calls the twitter API.

The wrapper functions provide an intuitive MATLAB-style interface for accessing the twitter's API resources. The API is quite extensive and twitty doesn't cover it all. It includes most of the resources in the following sections: TIMELINE, TWEETS, SEARCH, FRIENDS & FOLLOWERS, USERS, ACCOUNTS, PLACES & GEO, and HELP.

For the complete summary of the twitty's interface functions run 'twitty.API'.
For information on a particular function, type 'help twitty.<function name>'.
For the help on twitty, type 'help twitty'.

REQUIREMENTS:
    optional - the json parser by Joel Feenstra: http://www.mathworks.co.uk/matlabcentral/fileexchange/20565-json-parser

Acknowledgements

The author wishes to acknowledge the following in the creation of this submission:
Update twitter status

MATLAB release MATLAB 7.11 (2010b)
Other requirements parse_json.m (optional)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (6)
04 Feb 2012 Beaver

Disregard... I didn't read the twitter api suggestions. Great Code... Under promises, Over Delivers!!

15 Feb 2012 Justin

Not sure if I'm just doing something wrong but I can't seem to get this going. Whenever you try to set or save the credentials it returns an error

Conversion to logical from cell is not possible.

23 Apr 2012 Michael Antaran

Looks great. However, can you provide an example file format of how the credentials files should look like.

Sorry if this is a novice question. See potential but having difficult time using on 2007b.

thanks

26 Apr 2012 Yu Ang Tan

Justin: change line 136:
if strfind(lower(S),'error'))...
to
if strfind(lower(S{1}),'error'))...

Michael: create a structure
credentials.ConsumerKey='SH1asd325tgdsasOVedYsA';
credentials.ConsumerSecret = 'on325gtgafafdsfegawe4365ghgSDF';
credentials.AccessToken = '123554-PZjoiso98n3ocrlWFOJ39rjlsjfwzOdq';
credentials.AccessTokenSecret = 'W6r324fjlajaMMLasffSMMk';
tw = twitty(credentials);

You'll need to replace those strings from your developer page. The strings above are just garbage values.

26 Apr 2012 Vladimir Bondarenko

@Yu Ang Tan: thanks for the comment. I've fixed the strfind(lower(S),'error') issue.

@Justin: did it resolve your problem?

@Michael: I replied to your email, but my reply couldn't be delivered ("no such user" error). Do you have an alternative email address?

07 May 2012 Jose

I am trying to use the function friendshipsCreate and it gives me the following message...

>> S = tw.friendshipsCreate('pepe','matlab','follow','true')

??? Java exception occurred:
ice.net.URLNotFoundException: Document not found on server
at ice.net.HttpURLConnection.getInputStream(OEAB)

Error in ==> twitty>twitty.callTwitterAPI at 2018
        inStream = BufferedReader( InputStreamReader(
        httpConn.getInputStream ) );

Error in ==> twitty>twitty.friendshipsCreate at 1128
            S =
            twtr.callTwitterAPI(httpMethod,url,params,1);

Please login to add a comment or rating.
Updates
26 Apr 2012

Some documentation updates.
Fixes: strfind(lower(S),'error') is changed to strfind(lower(S{1}),'error') in the constructor function, twitty().

Tag Activity for this File
Tag Applied By Date/Time
twitter Vladimir Bondarenko 30 Jan 2012 09:53:49
web service Vladimir Bondarenko 30 Jan 2012 09:53:50
api Vladimir Bondarenko 30 Jan 2012 09:53:50
twitter Alec 02 Feb 2012 13:38:36

Contact us at files@mathworks.com