Twitter single token Status Update alias

Moderator: GeekShed.Net Staff

Twitter single token Status Update alias

Postby Ford » Wed Sep 15, 2010 5:35 pm

First: THIS WILL NOT WORK WITH mIRC 7.X!!!!!!!
The encoding to make the signatures for OAuth Authentication require the unicode character "pairs" that no longer exist in mIRC. At some point I will adapt some code for this but it's not really high on my list. Perhaps I'll get lucky and Khaled will add a proper hmac-sha1 identifier as nearly all other languages have.
Anyhow, this script will only work with 6.3x, due to a lack of a sha1 identifier in older versions.

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.

Code: Select all
;twitter_statuses_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::;
;;;;;;;;;;;;;;;
;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 twitter_statuses_update {
  var %ots $gmt, %sockname $+(twitter_statuses_update,$network,$ticks,$r(1,10000)), %once $md5(%sockname)
  var %os $signature(post,http://twitter.com/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($tuenc(%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 /statuses/update.xml HTTP/1.1
    sockwrite -n $sockname Host: twitter.com
    sockwrite -n $sockname User-Agent: Lawnmower 9.64
    sockwrite -n $sockname Authorization: OAuth realm="/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
  }
}
on *:sockread:twitter_statuses_update*: {
  if ($sockerr) { $gettok($sock($sockname).mark,1-2,32) Unknown Socket error $nopath($script) }
  else {
    var %twitter_statuses_updatevar | sockread %twitter_statuses_updatevar
    if (HTTP/1.1 401 isin %twitter_statuses_updatevar) {
      $gettok($sock($sockname).mark,1-2,32) Password/Username Error --> %twitter_statuses_updatevar
      sockclose $sockname | return
    }
    elseif (HTTP/1.1 502 isin %twitter_statuses_updatevar) || (HTTP/1.1 503 isin %twitter_statuses_updatevar) {
      $gettok($sock($sockname).mark,1-2,32) Server Busy Error --> %twitter_statuses_updatevar
      sockclose $sockname | return
    }
    elseif (HTTP/1.1 500 isin %twitter_statuses_updatevar) {
      $gettok($sock($sockname).mark,1-2,32) Server Side Error --> %twitter_statuses_updatevar
      sockclose $sockname | return     
    }
    elseif (HTTP/1.1 403 isin %twitter_statuses_updatevar) {
      $gettok($sock($sockname).mark,1-2,32) Connection Actively Refused --> %twitter_statuses_updatevar
      sockclose $sockname | return     
    }
    elseif (HTTP/1.1 400 isin %twitter_statuses_updatevar) {
      $gettok($sock($sockname).mark,1-2,32) Unknown Error --> %twitter_statuses_updatevar
      sockclose $sockname | return
    }
    elseif (HTTP/1.1 200 isin %twitter_statuses_updatevar) {
      $gettok($sock($sockname).mark,1-2,32) Updating Status Please Wait.........
    }
    elseif (</status> isin %twitter_statuses_updatevar) {
      .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 space2comma return $replace($1-,$chr(32),$chr(44))
alias -l hmacsha1 {
  var %key $iif($len($1) <= 64,$1,$hex2chr($sha1($1))), %ipad $xorall($str(6,64),%key), %opad = $xorall(%opad $str(\,64),%key), %message $2
  $iif($isid,return,echo -a) $encode($hex2chr($sha1($+(%opad,$hex2chr($sha1($+(%ipad,%message)))))),m)
}
alias -l hex2chr { return $regsubex($1,/(.{2})/g,$chr($base(\t,16,10))) }
alias -l xorall {
  var %end $iif($len($1) > $len($2),$len($1),$len($2)), %p $1, %k $2
  return $regsubex($str(.,%end),/(.)/g,$chr($xor($iif($asc($mid(%p,\n,1)),$v1,0),$iif($asc($mid(%k,\n,1)),$v1,0))))
}
alias -l tuenc& return $tuenc($+($1,&))
Ford
 
Posts: 48
Joined: Wed Oct 28, 2009 1:01 am

Re: Twitter single token Status Update alias

Postby GrimReaper » Sat Sep 25, 2010 11:52 pm

Work's like a charm, Was easy to set up with the direction's given as well.

:) Awesome work Ford.
GrimReaper
 
Posts: 73
Joined: Wed Oct 28, 2009 4:34 pm
Location: In your router, Resetting your connection.


Return to Script help

Who is online

Users browsing this forum: No registered users and 15 guests

cron