Tweet from Max with ruby

Update 6/2014: working version here: https://reactivemusic.net/?p=7013

notes

The zapier.com trigger method of sending tweets from Max is limited by number of tweets and sync rate. So it would be nice to set up another intermediary server program in ruby or php which eliminates the middle-man and just sends tweets directly.

Or you could use the mxj searchTweet program, which has been updated to do this on the search side.

twitter gem

update: Got it working with this gem: https://github.com/sferik/twitter. Its much easier than dealing with xively.

docs: http://rdoc.info/gems/twitter

how to destroy a tweet: http://stackoverflow.com/questions/10640811/twitter-gem-how-to-get-the-id-of-a-new-tweet

how to get a timeline: http://bobbyprabowo.wordpress.com/2010/01/01/simple-twitter-gem-tutorial/

example of error handling code:

MAX_ATTEMPTS = 3
num_attempts = 0
begin
  num_attempts += 1
  retweets = Twitter.retweeted_by_user("sferik")
rescue Twitter::Error::TooManyRequests => error
  if num_attempts <= MAX_ATTEMPTS
    # NOTE: Your process could go to sleep for up to 15 minutes but if you
    # retry any sooner, it will almost certainly fail with the same exception.
    sleep error.rate_limit.reset_in
    retry
  else
    raise
  end
end

 

Another useful SO post: http://stackoverflow.com/questions/16618037/twitter-rate-limit-hit-while-requesting-friends-with-ruby-gem/16620639#16620639

 

How to set up Max Twitter triggers with Xively and Zapier

note: 6/2021 – Everything on this post no longer works, except the idea. See Internetsensors posts for current methods

notes

pachube.com and cosm.com have now changed into xively.com. Also Twitter has migrated to the version 1.1 API. The old method of sending tweets with cosm.com no longer works as of of June 2013.

Here are revised instructions for setting up an intermediary program that allows you to send Tweets from Max/MSP using a xively.com “device” (feed). This setup is required by the tweetCurl patches in the Max/MSP internet sensors project:

https://reactivemusic.net/?p=5859

Summary: the Max program will issue an http: put request to your xively.com feed with the Tweet text as data. When the data is received it triggers a request to xapier.com which logs into your Twitter account and sends the Tweet. xapier.com handles authentication using Oauth.

1. set up a xively.com account (self explanatory)

2. add a device. From the xively.com home page select “develop” from the “web tools” menu. You’ll get a screen like this one:

Click on +add device. The following screen will appear:

Fill in the fields. The names and choices can be whatever you want.  Then click the “Add Device” box to get the following screen:

Now click on +Add Channel. Fill in the Channel ID field with the name: tweet (as shown below) then click the “save channel” box.

3. Add Trigger. The trigger will link this channel to Twitter. Please follow the instructions here: https://xively.com/dev/tutorials/zapier/

Notes:

  • You will need to sign up for a free zapier account
  • assign Twitter as your action service for the “zap”
  • For the ‘message’ field of your zap select “body trigger datastream value value”. This will be the actual text of the tweet coming from xively.com
  • limited to 10 tweets per hour
  • when you select twitter as an action in zapier, it will attempt to log you in to do the oauth authentication. If you are already logged into Twitter – make sure its the correct account.
  • zapier will provide you with the URL to insert into the trigger field in your xively.com device.
4. From the xively.com device screen copy the feed-ID and API-key into your Max patch in the appropriate fields.

 

 

 

 

Hatsune Miku

A vocaloid character

http://en.wikipedia.org/wiki/Hatsune_Miku

(from Wikipedia)

Hatsune Miku (初音ミク?) is a singing synthesizer application with a humanoid persona, developed by Crypton Future Media. It uses Yamaha Corporation‘s Vocaloid 2 and Vocaloid 3 singing synthesizing technology. She was the second Vocaloid sold using the Vocaloid 2 engine, and the first Japanese Vocaloid to use the Japanese version of the Vocaloid 2 engine. Her voice is sampled from Japanese voice actress, Saki Fujita. Hatsune Miku has performed at her concerts onstage as an animated projection.[1] Hatsune Miku is portrayed to be a 16-year-old girl with long teal pigtails.

http://www.youtube.com/watch?v=rL5YKZ9ecpg

An example in Max

by FitanyCereal