Simple way to post a Twitter status update with VBScript or Perl
I'm running VBScript on IIS 6, and I need to post status updates to a single Twitter account. This would have been easy a couple of years ago 开发者_Python百科(like, four lines of code), but Twitter decided to abandon sensible authentication in favor of some monstrosity called OAuth that seems to require multiple requests and callbacks in order to perform even the simplest tasks. There is a library for using OAuth in VBScript, and while it would save me from writing my own hmac and sha1 libraries, it doesn't remove the fundamental complexity of the system. It looks like it would be very helpful if I intended to use more than one account, or save credentials, or something other than post a few words to a single Twitter account.
What I'd like to do is find a simple way to post one single status update to one single constant Twitter account.
If this is not possible in VBScript, I can call a Perl script, although this comes with its own set of headaches. A VBScript solution, if it exists, would be really nice.
Note: this question is similar, but it's been a couple of years and both the problem (Twitter's authentication) and the solutions (available code) have changed since then.
If you do it in Perl, the Net::Twitter module on CPAN will be of use, it can handle the OAuth stuff for you (although I'll admit I don't like OAuth). Net::Twitter::Lite provides similar functionality but without the overhead of loading Moose.
This writeup on the demise of basic authentication for Twitter shows some simple-looking examples like:
use Net::Twitter::Lite;
my $nt = Net::Twitter::Lite->new(
consumer_key => $YOUR_CONSUMER_KEY,
consumer_secret => $YOUR_CONSUMER_SECRET,
access_token => $YOUR_ACCESS_TOKEN,
access_token_secret => $YOUR_ACCESS_TOKEN_SECRET,
);
$nt->update("Bob's your uncle!");
To get the consumer_key, consumer_secret, access_token and access_token_secret, you'll need to register your application with Twitter.
精彩评论