I was looking a way to add a very simple twitter functionality into my script and was surprised to find out that after Twitter shut down basic authentication there's no simple way to just 开发者_JAVA技巧send a stupid tweet from your script. Every approach I found requires special modules which has several dependencies. Moreover none of the examples I found in internets worked for me. Could someone please help me to find simple and elegant way to send a tweet from a perl script using OAuth?
P.S. The only conceivable example I found was this Ruby code: http://twoism.posterous.com/a-no-bullshit-twitter-oauth-example
Short version: Twitter uses OpenAuth, there's nothing you can do about that, if you're going to use the API and do it properly.
Long version:
- Twitter requires OpenAuth
- Perhaps unfortunately, the latest Net::Twitter module, which you need because of the OpenAuth, does use Moose and have a lot of dependencies
- But ... if you have a problem installing modules, then that's big issue and a separate issue. You're going to have to get past this or stop asking questions of Perl programmers, because they won't be sympathetic. Knowing how to handle modules is part of being a good programmer.
- If it's really insurmountable right now, maybe you could get around it by using WWW::Mechanize to script Twitter interaction as if doing it by browser?
I've never tried it that way but it might work.
To be able to send a simple tweet you may need to communicate with the Twitter server using https (as per the Ruby code example) which will require you to have an SSL library. The Ruby code you reference relies on 7 external libraries of which 4 are specifically required to support https/SSL.
At the very least, you'll need LWP with baked-in support for SSL, which requires the OpenSSL libraries and programs which can be downloaded from http://www.openssl.org/ or if you are running under Linux, you should be able to use the platform specific package manager.
精彩评论