1

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

rcknr
  • 245
  • 2
  • 13
  • 1
    Related: http://stackoverflow.com/questions/5008774/simple-way-to-post-a-twitter-status-update-with-vbscript-or-perl http://stackoverflow.com/questions/3823563/how-can-i-update-my-twitter-status-with-perl-and-only-lwpuseragent – daxim Jun 20 '11 at 17:22
  • Be detailed and constructive: explain what exactly you tried and what did not work. – daxim Jun 20 '11 at 17:31
  • And what platform you are using (Windows, Mac, Linux)? – Rob Raisch Jun 20 '11 at 17:35
  • None of the related articles you cited provide a valid answer. I´m using several environments none of which allows me to install modules. I tried several modules on one of the server but this doesn´t qualify as an elegant solution. I mean installing a 2 megs library for sending 140 character messages once in a while. – rcknr Jun 20 '11 at 18:27
  • 1
    You're new here - so welcome. People want help you with investing time answering your question. Please, be polite. If you know better way as you already get suggested - simply post the better answer. Community will vote. Enjoy SO. ;) – clt60 Jun 20 '11 at 19:26
  • jm666, luckily I've found an interesting approach elsewhere. If it work well I'll post it here of course. – rcknr Jun 20 '11 at 21:20
  • It's not Perl's, or Ruby's fault; Twitter wants OAuth validation, and that requires extra work. It would be trivial to get 140 characters into the hands of the President too if it weren't for bureaucracy and security layers. – DavidO Jun 21 '11 at 00:38
  • 1
    Serg, so your real problem is that you think you cannot install modules. That surely can be helped, you should have mentioned this piece of information in the beginning. Please add the details what makes you think so to your question (this means writing more than "it didn't work"!), or open a new question if the advice from http://stackoverflow.com/q/65865 did not clear everything up already. – daxim Jun 21 '11 at 08:14
  • 2
    Going against the grain of the Perl culture (using library code) is not advisable. You want little code: [can't get shorter than the 3 lines](http://p3rl.org/Net::Twitter::Lite#SYNOPSIS) `use … new … update`. The module has only 5 direct non-core dependencies and installed within a minute on my Linux systems just fine. – daxim Jun 21 '11 at 08:15

2 Answers2

2

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.

AmbroseChapel
  • 11,957
  • 7
  • 46
  • 68
1

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.

Rob Raisch
  • 17,040
  • 4
  • 48
  • 58
  • I´m not good in Ruby but I like the approach of this guy. I´m looking for easiest way to post a single tweet with as less code as possible. – rcknr Jun 20 '11 at 18:34
  • From everything I've seen regarding the topic, I found this solution as the most elegant for simple tweet sedning: http://jims-tech.blogspot.com/2011/03/twitter-oauth-perl-module.html – rcknr Jun 20 '11 at 21:33