/ Published in: R
URL: http://rebol.wik.is/Code_Samples/Tweet.r
Expand |
Embed | Plain Text
REBOL [ file: %tweeter.r title: "To twit or not to twit" author: "Graham Chiu" date: 19-May-2009 rights: 'BSD purpose: {to update twitter status} notes: {this script uses basic authentication, and twitter is turning that OFF on 31/Aug/2010} ] view/new center-face layout [ across label "Message:" return noticearea: area 280x60 return label "Userid: " 70 userfld: field return label "Password: " 70 passfld: field return btn "Tweet" [tweet] #"^S" btn "Quit" [ unview/all halt ] #"^Q" do [ focus noticearea ] ] tweet: has [tw page err len] [ if 140 < len: length? noticearea/text [ alert rejoin [ "Only allowed 140 chars, and you have " len ] return ] if any [ empty? noticearea/text empty? userfld/text empty? passfld/text ][ alert "All fields need to be filled in!" focus noticearea return ] tw: flash "Tweeting ... " if error? set/any 'err try [ page: read/custom compose/deep [ scheme: 'http host: "twitter.com" target: "statuses/update.xml" user: (userfld/text) pass: (passfld/text) ] reduce ['POST rejoin ["status=" noticearea/text]] unview/only tw alert "Message tweeted" ] [ unview/only tw err: mold disarm err either find err "no-connect" [ alert "No network connection to twitter.com" ] [ either find err "Unauthorized" [ alert "Your twitter credentials are not recognized." ] [ alert err ] ] ] ] do-events
You need to login to post a comment.
