Twitter has a super easy way of updating twitter statuses via URL, but the awesome Wez Crozier and I came across some issues. But first to how you do this:
var url:String = "http://twitter.com/home?status=";
First note: do not try www.twitter.com, because it will not work. Your escaped items (mainly Hashtags # == %23) will not be unescaped for you. Props to Wez for that one.
Here's some awesome RegEx code Wez figured out for me too (I suck at RegEx):
var textToPostToTwitter:String = postText.text;
var input:String = url+textToPostToTwitter;
var output:String = input.replace(new RegExp(/\s/g), "+");
output = output.replace(new RegExp(/\#/g), "%23");
Something that I figured out because I was trying to be lazy and sneaky was that you have to replace the whole String. I mean you can't just replace the String you want as the status and do a url + input.replace(new RegExp(/\s/g), "+");.
So, I hope that helps some of you guys not fall into the trap we did. And thanks again Wez, you rock.
Follow Wez at: twitter.com/obwez
And use Grant Skinner's awesome RegExr.
How to Improve Your Programming and Coding Workflow - When you think about the IT domain, there’s more to it than just websites and apps. However, these don’t just appear out of nowhere, but someone creates th...
10 months ago