Twitter single token status update

By FordLawnmower on Sep 15, 2010

First: THIS WILL WORK WITH mIRC 7.X!!!!!!!
Tested clean on 6.3x and 7.x on both XP and Windows 7.
This script has been changed a little to use a dll for encoding.
If you are using an older version of this script please replace it with this one. The old version has some flaws that could cause a unwarranted UserName/Password Error.

To the script::
This script will allow you to update your status with your "own twitter application" information.
The result will be a twitter update like this:

"Testing mirc script"
"35 minutes ago via YourAppNameWillBeHere"

In addition to your app name being posted, this is quite an awesome spammer because you can associate whatever link you want with your appname.

START HERE:

  • Go here -->> http://dev.twitter.com/apps/new
  • Fill in all the boxes
  • Application Name: Will Posted after each tweet (ie via Application Name)
  • Description: Anything you want here.
  • Application Website: Will be linked to the application name in each tweet. (spam your website here)
  • Anything you want here. Only shows on the apps page.
  • Application Type: Click "Client".
  • Default Access type: Click "Read & Write".
  • Application Icon: You can skip this for now.
  • Enter the Captcha
  • Click "Register Application"

Now you have registered your first app :)
You can always go to http://dev.twitter.com/apps/ and see your apps.

Image

Now you just need to get the keys and secrets and put them in the script:

  • Copy the code from this page and paste it to a new remote in the mIRC script editor. (keep this window open)
  • Click on your application (if needed)
  • Scroll down to Consumer key
  • Copy the key and paste it over top of "PutYourConsumerKeyHere" in the consumer_key alias at the top of the mIRC script.
  • Scroll to Consumer secret
  • Copy and paste it over "PutYourConsumerSecretHere" in the consumer_secret alias.
  • Now - On the right pane of your applications page - Click "My Access Token"
  • Copy the token under "Access Token (oauth_token)" and paste it over "PutYourOauthTokenHere" in the oauth_token alias.
  • Copy the token under "Access Token Secret (oauth_token_secret)" over "PutYourOauthTokenSecretHere" in the oauth_token_secret alias.
  • Save the script with a unique filename and you are ready to tweet :)

Now to send an update just type /quick_update your status update here.

;Twitter single token status update by Ford_Lawnmower irc.GeekShed.net #Script-Help
;;;;;;;;;;;;;;;;;
;::Start Setup::;
;;;;;;;;;;;;;;;;;
;Edit the lines below to reflect your Twitter Application info.
alias -l consumer_key return PutYourConsumerKeyHere
alias -l consumer_secret return PutYourConsumerSecretHere
alias -l oauth_token return PutYourOauthTokenHere
alias -l oauth_token_secret return PutYourOauthTokenSecretHere
;;;;;;;;;;;;;;;
;::End Setup::;
;;;;;;;;;;;;;;;
alias -l mIRCTwitter mTwitterGetStatus echo -a $consumer_key $consumer_secret $oauth_token $oauth_token_secret
alias quick_update mTwitterUpdate echo -a $consumer_key $consumer_secret $oauth_token $oauth_token_secret $1-
;Syntax mTwitterUpdate echo -a consumer_key consumer_secret oauth_token oauth_token_secret status update here
;Note that echo -a can be changed to msg $chan or notice $nick ( must be two words )
alias -l mTwitterUpdate {
  var %ots $ctime, %sockname mIRCTwitterUpdate, %once $md5(%sockname)
  var %os $signature(post,http://api.twitter.com/1.1/statuses/update.json,$3,$4,$5,$6,%once,%ots,$+(status=,$tuenc($7-)))
  .sockclose %sockname
  sockopen %sockname api.twitter.com 80
  sockmark %sockname $1-2 $space2comma($+(oauth_nonce=,$qt(%once)) $osmqt $+(oauth_timestamp=,$qt(%ots)) $+(oauth_consumer_key=,$qt($tuenc($3))) $&
    $+(oauth_token=,$qt($tuenc($5))) $+(oauth_signature=,$qt($suenc(%os))) $overqt) $+(status=,$tuenc($7-))
}
on *:sockopen:mIRCTwitterUpdate: {
  if ($sockerr) echo -st Socket Error $nopath($script)
  else {
    tokenize 32 $sock($sockname).mark
    sockwrite -n $sockname POST /1.1/statuses/update.json HTTP/1.1
    sockwrite -n $sockname Host: api.twitter.com
    sockwrite -n $sockname User-Agent: Lawnmower 9.64
    sockwrite -n $sockname Authorization: OAuth realm="/1.1/statuses/update.json", $3
    sockwrite -n $sockname Content-Type: application/x-www-form-urlencoded
    sockwrite -n $sockname Content-Length: $len($4)
    sockwrite -n $sockname
    sockwrite -n $sockname $4
    sockwrite -n $sockname
  }
}
on *:sockread:mIRCTwitterUpdate: {
  if ($sockerr) { $gettok($sock($sockname).mark,1-2,32) Unknown Socket error $nopath($script) }
  else {
    var %mTwitterUpdatevar | sockread %mTwitterUpdatevar
    if (HTTP/1.1 401 isin %mTwitterUpdatevar) {
      $gettok($sock($sockname).mark,1-2,32) Password/Username Error --> %mTwitterUpdatevar
      sockclose $sockname | return
    }
    elseif (HTTP/1.1 502 isin %mTwitterUpdatevar) || (HTTP/1.1 503 isin %mTwitterUpdatevar) {
      $gettok($sock($sockname).mark,1-2,32) Server Busy Error --> %mTwitterUpdatevar
      sockclose $sockname | return
    }
    elseif (HTTP/1.1 500 isin %mTwitterUpdatevar) {
      $gettok($sock($sockname).mark,1-2,32) Server Side Error --> %mTwitterUpdatevar
      sockclose $sockname | return      
    }
    elseif (HTTP/1.1 403 isin %mTwitterUpdatevar) {
      $gettok($sock($sockname).mark,1-2,32) Connection Actively Refused --> %mTwitterUpdatevar
      sockclose $sockname | return      
    }
    elseif (HTTP/1.1 400 isin %mTwitterUpdatevar) {
      $gettok($sock($sockname).mark,1-2,32) Unknown Error --> %mTwitterUpdatevar
      sockclose $sockname | return
    }
    elseif (HTTP/1.1 200 isin %mTwitterUpdatevar) {
      $gettok($sock($sockname).mark,1-2,32) Updating Status Please Wait.........
    }
    elseif (status: 200 OK isin %mTwitterUpdatevar) {
      .timer 1 3 $gettok($sock($sockname).mark,1-2,32) Your Status has been updated :)
      sockclose $sockname | return
    }
  }
}
;Syntax $signature(POST/GET,URL,consumer_key,consumer_secret,oauth_token,oauth_token_secret,oauth_nonce,oauth_timestamp,PostData)
alias -l signature {
  var %method $+($upper($1),&), %url $+($tuenc($2),&), %ck $tuenc&($+(oauth_consumer_key=,$3)), %ot $tuenc&($+(oauth_token=,$5))
  var %once $tuenc&($+(oauth_nonce=,$7)), %ots $tuenc&($+(oauth_timestamp=,$8)), %post $iif($9-,$tuenc($+(&,$9-)))
  return $hmacsha1($+($4,&,$iif($6,$6)),$+(%method,%url,%ck,%once,$tuenc&($osm),%ots,%ot,$tuenc($over),%post))
}
alias -l osm return oauth_signature_method=HMAC-SHA1
alias -l osmqt return oauth_signature_method="HMAC-SHA1"
alias -l over return oauth_version=1.0
alias -l overqt return oauth_version="1.0"
alias -l tuenc return $regsubex($replace($1-,+,$chr(32)),/([^a-z0-9._-])/ig,% $+ $base($asc(\t),10,16,2))
alias -l suenc return $regsubex($1-,/([^a-z0-9._-])/ig,% $+ $base($asc(\t),10,16,2))
alias -l space2comma return $replace($1-,$chr(32),$chr(44))
alias -l tuenc& return $tuenc($+($1,&))
;hmacsha1 by Ford_Lawnmower irc.GeekShed.net #Script-Help
;Syntax hmacsha1 key message or $hmacsha1(key,message)
alias -l hmacsha1 {
  var %key $1, %data $2
  bset -c &key 1 $regsubex(%key,/(.)/g, $asc(\1) $chr(32))
  bset -c &data 1 $regsubex(%data,/(.)/g, $asc(\1) $chr(32))
  if ($bvar(&key,0) > 64) bset -c &key 1 $hex2chr($sha1(&key,1))
  bset -c &ipad 1 $xorall($str($+(54,$chr(32)),64),$bvar(&key,1-))
  bset -c &opad 1 $xorall($str($+(92,$chr(32)),64),$bvar(&key,1-))
  bcopy &ipad $calc($bvar(&ipad,0) + 1) &data 1 -1
  bset -c &ipad 1 $hex2chr($sha1(&ipad,1))
  bcopy &opad $calc($bvar(&opad,0) + 1) &ipad 1 -1
  bset -c &return 1 $hex2chr($sha1(&opad,1))
  noop $encode(&return, mb)
  $iif($isid,return,$iif(#,say,echo -a)) $bvar(&return, 1-).text
}
alias -l hex2chr return $regsubex($1-,/(.{2})/g, $base(\t,16,10) $chr(32))
alias -l xorall {
  var %p $1, %k $2, %end $iif($regex($1,/([\d]{1,})/g) > $regex($2,/([\d]{1,})/g),$v1,$v2)
  return $regsubex($str(.,%end),/(.)/g,$+($xor($iif($gettok(%p,\n,32),$v1,0),$iif($gettok(%k,\n,32),$v1,0)),$chr(32)))
}

Comments

Sign in to comment.
TomCoyote   -  Nov 09, 2017

Hiyas Ford! fordlawnmower.googlecode.com /files/hmacsha1 $nospace($mircdirhmacsha1) hmacsha1.exe
(file is not available on this server)
Do you have it stashed somewhere?

 Respond  
Codica   -  Sep 21, 2014

I keep getting 403 -> Actively Refused errors...

Jimieo  -  May 21, 2015

Same here.

Sign in to comment

Chromatic   -  Aug 04, 2013

...

 Respond  
cantthink96   -  Jul 31, 2013

Hey LawnMower, long time no talk or see. I'm currently working on detailed things. Using api and such, i was wondering if you would help me if so my skype is cantthink96 my twitter is stolenhope and i'm hoping you can help me. Let me know as soon as possible

 Respond  
  -  Jun 06, 2013

twitter api 1.0 ends on June 11. Is this api 1.1 ready?

FordLawnmower  -  Jun 07, 2013

This script is updated and working with twitters api 1.1.
Strange , I had the wrong snippet posted here. This script adds a /quick_update command so you can update your status from mIRC or use it in scripts. I had the twitter stream script posted here for some reason. I will be updating the twitter stream script in a few minutes.

 -  Jun 07, 2013

update works well. thanks!

FordLawnmower  -  Jun 07, 2013

Cool . Thanks for the reminders @

squigradio  -  Jun 21, 2013

Hey all. How do I fix this error coming up, which appears to be preventing tweeting from MIRC? "* Line too long: $regsubex (line 92, twitter.mrc)"

I copied and pasted the snippet directly from above into plaintext so there should be no extra characters or hard returns. I pasted in my consumer and token codes that I previously received.

FordLawnmower  -  Jun 21, 2013

What is your mIRC version @squigradio ?

squigradio  -  Jun 22, 2013

6.3

FordLawnmower  -  Jun 22, 2013

You need to upgrade to at least 6.32 @squigradio . 6.3 has a very low variable limit , newer versions have 10 x larger variable limit. I would suggest 6.35 if you don't want to move up to the current version.
http://lmgtfy.com/?q=mirc+6.35+download
To upgrade you only need to replace your mIRC.exe with the new one.
Just the .exe : https://anonfiles.com/file/0e4769952b2765cc252c9fb7d9b19664

squigradio  -  Jun 24, 2013

Back in business!! Thanks Ford!

squigradio  -  Jun 26, 2014

What's the command to make this update these days? /update_tweet or whatever it used to be is now coming up as not valid. /quick_update does nothing; no error message or output or anything.

SquigY0  -  Aug 28, 2014

Hello?

Sign in to comment

moneyect   -  Nov 28, 2012

I just figured out that you use the command /mIRCTweet to send an update via the script listed at the top of this thread.
It works for me.
However I sill cant get the ones listed in the pastebin to work, as I stated, posting /quick_update message does nothing, no error message no nothing happens.
any idea why?

 Respond  
moneyect   -  Nov 28, 2012

hello, I been using your script off and on for a while now.
I started using it again, well tried to and its failing to work.
I never changed anything in mirc, what happens is, when I try to send an update, nothing at all happens, no error message either.
this is using V 7.15 mirc, I tried all versions posted here, same results.
I also created a new Mirc using V 6.1.5 and I then get an error
( invalid line 19 $signature)- something to that affect

BTW, the script at the very top of this page, the main code, as far as I have figured out, you dont update your status with the "/quick_update" command, I just typed my message in the @twitter window, and it tweets for me, just figured that out, at first I thought it was only a script to retrieve your timeline.

You need to fix your info on how to use the status update feature of this script (quick_update) does nothing except give an unknown command error message.

I would really love to be able to use the original single status update script that does use the (/quick_update) command as I have coded my own spammer bot to auto tweet for me,

none of the ones listed here in the pastebin links work for me, as I said, nothing happens when I /quick_update message.
if I change one digit in my consumer code, I then get the ""Password/Username Error --> HTTP/1.1 401 Unauthorized" message, which tells me the script is trying to work.

If you wish, my email is gypsyr0ads @ live com
no spaces, ;)

Ill check back here later to see if you replied.
thanks for the scripts BTW
the ones that do work are great to have

 Respond  
SquigY0   -  Oct 25, 2012

Thanks! You guys are always so helpful on here!

 Respond  
FordLawnmower   -  Oct 24, 2012

@SquigY0 That error is part of the code, added by me. You will get that error whenever twitters api is overloaded.
There is nothing wrong with the script, the problem is with twitter, and this has been an issue from the first day of the api.
You can see the recent history of service outages here: http://api-status.com/detail/113966 .
Official status page: https://dev.twitter.com/status
If you would like to suppress this error, you can do so by editing line 62 .

 Respond  
SquigY0   -  Oct 24, 2012

Should this also address "Socket Error twitter.mrc" which I've been getting since near the beginning of the month? Nothing changed on my end that coincides.

 Respond  
FordLawnmower   -  Oct 15, 2012

Updated to adapt to changes in api path.

 Respond  
Grimnir   -  Oct 15, 2012

I was getting the same thing. I fin you have to change that top section to this:
;===============================================================================
;Syntax quick_update update text here note requires that you complete setup
alias quick_update twitter_statuses_update echo -a $consumer_key $consumer_secret $oauth_token $oauth_token_secret $1-
;Syntax twitter_statuses_update echo -a consumer_key consumer_secret oauth_token oauth_token_secret status update here
;Note that echo -a can be changed to msg $chan or notice $nick ( must be two words )
alias -l twitter_statuses_update {
var %ots $gmt, %sockname $+(twitter_statuses_update,$network,$ticks,$r(1,10000)), %once $md5(%sockname)
var %os $signature(post,http://api.twitter.com/1/statuses/update.xml,$3,$4,$5,$6,%once,%ots,$+(status=,$tuenc($7-)))
sockopen %sockname twitter.com 80
sockmark %sockname $1-2 $space2comma($+(oauth_nonce=,$qt(%once)) $osmqt $+(oauth_timestamp=,$qt(%ots)) $+(oauth_consumer_key=,$qt($tuenc($3))) $&
$+(oauth_token=,$qt($tuenc($5))) $+(oauth_signature=,$qt($suenc(%os))) $overqt) $+(status=,$tuenc($7-))
}
on :sockopen:twitter_statuses_update: {
if ($sockerr) echo -st Socket Error $nopath($script)
else {
tokenize 32 $sock($sockname).mark
sockwrite -n $sockname POST /1/statuses/update.xml HTTP/1.1
sockwrite -n $sockname Host: api.twitter.com
sockwrite -n $sockname User-Agent: Lawnmower 9.64
sockwrite -n $sockname Authorization: OAuth realm="/1/statuses/update.xml", $3
sockwrite -n $sockname Content-Type: application/x-www-form-urlencoded
sockwrite -n $sockname Content-Length: $len($4)
sockwrite -n $sockname
sockwrite -n $sockname $4
sockwrite -n $sockname
}
}

 Respond  
NwoChat   -  Oct 15, 2012

When using this script I am now getting a password error.401 unauthorized error. Nothing has changed on my end that that I can think of that would cause this.

 Respond  
FordLawnmower   -  Jun 27, 2012

@S1R1US Please use the code at the top of this page.

 Respond  
S1R1US   -  Jun 26, 2012

got past the first error, now this one:

  • Loaded script 'C:\TDSiRC\twitterap.ini'
  • [12:20] Downloading App. Please wait........

  • /mkdir: insufficient parameters (line 118, twitterap.ini)

looking forward to getting this working. pretty sure I'm just doing something wrong. great work

 Respond  
S1R1US   -  Jun 26, 2012

This still work? I get * Invalid format: $signature (line 19, twitterap.ini)

 Respond  
FordLawnmower   -  Sep 08, 2011

This script works fine Aha2Y. I use this script 12 times everyday and I have tested it clean on XP and Win 7, 32 bit and 64 bit on both mIRC 6.35 and 7.x. I have also tested this repeatedly on different flavors of linux with wine.
It sounds to me like you have a script conflict of some sort. Don't see this line anywhere: > Authorization: OAuth realm="/statuses/update.xml", $3
My guess would be that your socket debug script is causing the problem. Try unloading it.

@sockdata 4Sockwrite failed you have specified a switch & socket name but no data.
Nothing fails here. It just called sending a blank line. The protocol for sending your update is BlankLine CRLF, Your Update, BlankLine CRLF. It won't work any other way.
If you still have problems after you unload the debugger thing, test the script with a blank mIRC.
If you still have problems then you need to go back to the top of the script and review your keys.

 Respond  
Jordyk19   -  Sep 08, 2011

This script doesn't work anymore.

Socket debug:

@sockdata 3Opening sock twitter_statuses_updateHardChats258668687021 3to ip twitter.com 3on port 80
@sockdata 3Sockwrite -n twitter_statuses_updateHardChats258668687021 POST /statuses/update.xml HTTP/1.1
@sockdata 3Sockwrite -n twitter_statuses_updateHardChats258668687021 Host: twitter.com
@sockdata 3Sockwrite -n twitter_statuses_updateHardChats258668687021 User-Agent: Lawnmower 9.64
@sockdata 3Sockwrite -n twitter_statuses_updateHardChats258668687021 Content-Type: application/x-www-form-urlencoded
@sockdata 3Sockwrite -n twitter_statuses_updateHardChats258668687021 Content-Length: 29
@sockdata 4Sockwrite failed you have specified a switch & socket name but no data. "sockwrite -n twitter_statuses_updateHardChats258668687021 data"
@sockdata 3Sockwrite -n twitter_statuses_updateHardChats258668687021 status=Test%201.%20AnonTweet.
@sockdata 4Sockwrite failed you have specified a switch & socket name but no data. "sockwrite -n twitter_statuses_updateHardChats258668687021 data"
Unknown Error --> HTTP/1.1 400 Bad Request
@sockdata 3Socket close twitter_statuses_updateHardChats258668687021 3, 3match was successfully closed.

 Respond  
FordLawnmower   -  Jul 11, 2011

@moocat tuenc is short for twitter url encode. This is the way that you must url encode to work with twitters api. This may be different for the site you are using but for twitter this is 100% correct and will NOT work any other way.
As for the sorting in the signature, I'm sure you could edit the signature alias for that, but this was only made to work with twitter status_update and was never posted as a universal Oauth Signature routine.
If I get some free time I'll look at some other sites and see what it would take to make one that has an easier syntax and works over a broader range of sites. By then they will force us to use Oauth 2.0 though ;/
What site are you using this for ?

 Respond  
moocat   -  Jul 11, 2011

Something else I stumbled over, as encoding the signature in the header is required some places, using $tuenc here will replace + with %20, which is not desired. (you want the normal value %2B)

Also some clarification on my last post: What I meant was you need to sort the params before putting it into the hmacsha1. For example if you used "status" as a param it would be put at the end of the params, and if you use something like "message" it will be in the front of params like before "oauth_nonce" etc. (Without it the signature will only support params with names from p-z)

 Respond  
FordLawnmower   -  Jul 10, 2011

@moocat this script is working fine and the signature is sorted properly already. Many changes have been made to this code since your last post, including changes to address the problems that your were having before.
Thanks for your interest in this script, as it was your post that caused me to take a closer look at this script and make it better :)

 Respond  
moocat   -  Jul 10, 2011

So I needed to do some OAuth in mIRC and decided to try again with this script and I found out why I was having problems before, as you haven't sorted the signature params like http://oauth.net/core/1.0/#sig_norm_param says. A simple $sorttok did the trick. Thanks again.

 Respond  
Cerrdor   -  Jun 12, 2011

@Ford how can I get this script to announce status updates in the IRC channel and not in @Twitter?

 Respond  
FordLawnmower   -  Jun 12, 2011

@Radien , please double check your api tokens/keys and make sure they are all correct and in the correct spot. If you are still having trouble, come to irc.geekshed.net , join #Script-Help and I will help you sort it out.
@Cerrdor This script will also broadcast your timeline -->> http://www.hawkee.com/snippet/7311/

 Respond  
Cerrdor   -  Jun 12, 2011

Worked fine for me, but will this gather updates and broadcast them in the room as well?

 Respond  
Radien   -  May 01, 2011

i'm getting a Password/Username Error --> HTTP/1.1 401 Unauthorized error >.<

 Respond  
FordLawnmower   -  Mar 16, 2011

Updated
Working with mIRC 6.3x-7.x
No .dll or external application needed :)

The .dll version is here if anyone still wants it -->> http://pastebin.com/kBxbqptx
External application version here -->> http://pastebin.com/CEnaQ6qj

 Respond  
FordLawnmower   -  Mar 14, 2011

For anyone who has had problems getting this script to work for whatever reason, here is an edit that I did for mIRC linux/wine -->> http://pastebin.com/CEnaQ6qj
Tested Clean with OpenSuse 11.2 and the newest build of wine with mIRC 7.19.

Also tested on :
mIRC 7.17 -- Windows 7 64/32 -- XP Pro 32
mIRC 6.35 -- Windows 7 32 -- XP Pro 32
No problems or issues found.

 Respond  
FordLawnmower   -  Mar 13, 2011

mIRC is not capable of encoding on this level needed for OAuth moocat . The problem with mIRC is the same one people encountered with VB6 when trying to apply hmac encoding to a (string,key) Because there is no native hmac function, conversions must be done between hexidecimal and ascii, in order to complete the encoding.
Sadly, what you have encountered is mIRC's inability to leave certain ascii characters alone even when you tell it not to touch them.

There are some solutions to this but they vary depending on your mIRC version and Windows version.
Sorry but I am so VERY tired of dealing with this, that is why I made the .dll . This is why I don' t take this project any farther. I just don't have the time to field all the mIRC related issues.
If the .dll is working for you, I would just use it. If not you can find me on irc.geekshed.net #Script-Help .
I can make you a script to call a php routine from mIRC. (You must have php installed on the same machine with your mIRC for this to work) .

So to clarify what I'm saying. The problem has nothing to do with the syntax for creating the OAuth signature, it's the inability of mIRC's $sha1() identifier to process certain ascii characters.

 Respond  
moocat   -  Mar 13, 2011

Tested with the pastebin you just posted http://pastebin.com/mvqi34Qs
here are the results http://pastebin.com/gC6cZZPP
Even though this example is not using Twitter's Oauth it's the signature method we're testing here so it makes no difference.

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.