File Exchange

image thumbnail

Update twitter status

version 1.4.0.1 (4.99 KB) by

Update your Twitter® status from MATLAB®

4 Downloads

Updated

View License

Using a MATLAB function update your status in Twitter.

Comments and Ratings (16)

If the default settings give 403 error then try changing line 81 to "url = URL('https://api.twitter.com/1.1/statuses/update.json');"

Orlando

Do I use the same "Application Name" and "Website" that you used in the M-file example? I don't have an application name to put there. Sorry. New at this.

Tobe freeman

Dear Navan Ruthramoorthy
Having troubles with an error message (below). Can you help?

I corrected/added the authentification details in twitter4j.properties but this didn't help.

Error using twit>throwError (line 136)
Authentication details were not correct.
Error in twit (line 120)
  throwError(ME.message);

Hi Michael,

Did you run javaaddpath as mentioned in my previous comment when you start MATLAB? You may need to add this to your startup file.

Navan-

It's back! This worked for me at one time.

??? Undefined variable "Base64" or class "Base64.encodeBase64".

Error in ==> twit>doHMAC_SHA1 at 160
    signStr = java.lang.String(Base64.encodeBase64(mac.doFinal(bytes)));

Error in ==> twit at 99
oauth_signature = doHMAC_SHA1(signStr, signKey);

Can you help me again.

thanks

Very useful! Thank you very much.

Michael and Menachem,
Sorry I did not check the code in R2007b after the update. Apache commons package is not available in R2007b. To make it work in R2007b you need to do the following.

1. Download the Apache commons codec binaries from http://commons.apache.org/codec/download_codec.cgi.
2. After you extract the binaries add the jar file to the java path using
javaaddpath('<pathtofile>/commons-codec-1.4.jar'). Replace <pathtofile> with the directory where you extracted the files.
3. In twit.m replace the line:114 which currently is
114: outputStream.write(java.lang.String(msgEncodedStrforPost).getBytes());

with the following two lines.

msgEncodedStrforPostString = java.lang.String(msgEncodedStrforPost);
outputStream.write(msgEncodedStrforPostString.getBytes());

After this it should work. Let me know if this helps.

From R2008a the Apache commans libraries are available and the code works without any changes.

Menachem

Hello, I just downloaded your program and got the same error as michael. I dont know if I am using your program correctly. I entered my twitter info and msg as strings.

thanks

??? Undefined variable "Base64" or class "Base64.encodeBase64".

Error in ==> twit>doHMAC_SHA1 at 160
    signStr = java.lang.String(Base64.encodeBase64(mac.doFinal(bytes)));

Error in ==> twit at 99
oauth_signature = doHMAC_SHA1(signStr, signKey);

Navan-
I've had a difficult time with the twitpref function.

I recieve an error referncing the base64... Here it is:

??? Undefined variable "Base64" or class "Base64.encodeBase64".

Error in ==> twit>doHMAC_SHA1 at 160
    signStr = java.lang.String(Base64.encodeBase64(mac.doFinal(bytes)));

Error in ==> twit at 99
oauth_signature = doHMAC_SHA1(signStr, signKey);

I understnad what it says but do not know how to fix it. I am using 2007b (32 and 64bit).
Please help.

Matthew Simoneau

Implementing OAuth in MATLAB. Very nice!

I have updated the script with OAuth support. The user needs to do a one time registration of the function as an application at twitter.com to get OAuth keys. The details are provided as part of help in the script. It is easy to use the function once you obtain the keys.

I look forward to the update.

Hi Matt, I am working on an update for the authentication method.

Matt Easton

This worked really well until Twitter changed their posting system. It now gives a response saying basic authentication is not accepted.

Michael Katz

Fun submission. You should check out http://www.mathworks.com/matlabcentral/fileexchange/6590 to get a password field for the user info GUI.

Updates

1.4.0.1

Updated license

1.4

Changed MATLAB release needed.

1.3

Updated script to support OAuth.

1.2

Updated script to make it work with OAuth.

MATLAB Release
MATLAB 7.6 (R2008a)

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video