使用 VBScript 或 Perl 发布 Twitter 状态更新的简单方法 [英] Simple way to post a Twitter status update with VBScript or Perl

查看:24
本文介绍了使用 VBScript 或 Perl 发布 Twitter 状态更新的简单方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 IIS 6 上运行 VBScript,我需要将状态更新发布到单个 Twitter 帐户.几年前这很容易(比如四行代码),但 Twitter 决定放弃合理的身份验证,转而使用一些称为 OAuth 的怪物,它似乎需要多个请求和回调才能执行最简单的任务.有一个在 VBScript 中使用 OAuth 的库,虽然它可以让我免于编写自己的 hmac 和 sha1 库,但它并没有消除系统的基本复杂性.如果我打算使用多个帐户,或者保存凭据,或者除了在单个 Twitter 帐户中发布几句话之外的其他内容,这看起来会很有帮助.

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 (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.

我想做的是找到一种简单的方法,将一个状态更新发布到一个固定的 Twitter 帐户.

What I'd like to do is find a simple way to post one single status update to one single constant Twitter account.

如果这在 VBScript 中是不可能的,我可以调用 Perl 脚本,尽管这会带来一些麻烦.一个 VBScript 解决方案(如果存在)会非常好.

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.

注意:这个问题很相似,但已经过去几年了从那时起,问题(Twitter 的身份验证)和解决方案(可用代码)发生了变化.

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.

推荐答案

如果你用 Perl 做,Net::Twitter 模块将很有用,它可以为您处理 OAuth 的内容(尽管我承认我不喜欢 OAuth).Net::Twitter::Lite提供类似的功能,但没有加载 Moose 的开销.

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.

这篇文章 关于 Twitter 基本身份验证的消亡显示了一些简单的示例,例如:

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!");

要获得 consumer_key、c​​onsumer_secret、access_token 和 access_token_secret,您需要在 Twitter 上注册您的应用程序.

To get the consumer_key, consumer_secret, access_token and access_token_secret, you'll need to register your application with Twitter.

这篇关于使用 VBScript 或 Perl 发布 Twitter 状态更新的简单方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆