Posted By

reboltutorial on 12/11/10


Tagged

twitterrebol


Versions (?)

Tweet


 / Published in: R
 

URL: http://rebol.wik.is/Code_Samples/Tweet.r

  1. REBOL [
  2. file: %tweeter.r
  3. title: "To twit or not to twit"
  4. author: "Graham Chiu"
  5. date: 19-May-2009
  6. rights: 'BSD
  7. purpose: {to update twitter status}
  8. notes: {this script uses basic authentication, and twitter is turning that OFF on 31/Aug/2010}
  9. ]
  10.  
  11. view/new center-face layout [
  12. across
  13. label "Message:" return
  14. noticearea: area 280x60 return
  15. label "Userid: " 70 userfld: field return
  16. label "Password: " 70 passfld: field return
  17. btn "Tweet" [tweet] #"^S" btn "Quit" [ unview/all halt ] #"^Q"
  18. do [ focus noticearea ]
  19. ]
  20.  
  21. tweet: has [tw page err len] [
  22. if 140 < len: length? noticearea/text [
  23. alert rejoin [ "Only allowed 140 chars, and you have " len ]
  24. return
  25. ]
  26. if any [ empty? noticearea/text empty? userfld/text empty? passfld/text ][
  27. alert "All fields need to be filled in!"
  28. focus noticearea
  29. return
  30. ]
  31. tw: flash "Tweeting ... "
  32. if error? set/any 'err try [
  33. page: read/custom
  34. compose/deep [
  35. scheme: 'http
  36. host: "twitter.com"
  37. target: "statuses/update.xml"
  38. user: (userfld/text)
  39. pass: (passfld/text)
  40. ]
  41. reduce ['POST rejoin ["status=" noticearea/text]]
  42. unview/only tw
  43. alert "Message tweeted"
  44. ] [
  45. unview/only tw
  46. err: mold disarm err
  47. either find err "no-connect" [
  48. alert "No network connection to twitter.com"
  49. ] [
  50. either find err "Unauthorized" [
  51. alert "Your twitter credentials are not recognized."
  52. ] [
  53. alert err
  54. ]
  55. ]
  56. ]
  57. ]
  58.  
  59. do-events

Report this snippet  

You need to login to post a comment.