homepage Welcome to WebmasterWorld Guest from 54.196.168.78
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / Perl Server Side CGI Scripting
Forum Library, Charter, Moderators: coopster & jatar k & phranque

Perl Server Side CGI Scripting Forum

    
WGET used for a Twitter software
The authentification problem
jetteroheller




msg:4169782
 7:18 am on Jul 14, 2010 (gmt 0)

I purchased in February TweetAdder Software.

But this software has so many time consuming bugs and so few features, that I feel forced to write my own Twitter software.

I use Perl and make the requests to Twitter.com with WGET.

Geting lists works fine, but now I want to sent follow and unfollow commands to Twitter requiring authentification.

First I tried the following call of WGET

"C:/Programme/GnuWin32/bin/wget.exe" --append-output=c:/twitter/twitter.log --server-response --save-headers --http-user=MYUSERNAME --http-password=MYPASSWORD --auth-no-challenge http://api.twitter.com/1/friendships/create.xml?user_id=27016367 --output-document=c:/twitter/_follow_sent.txt


After this failed always with 401 error, I tried to put direct a basic authentification line into --header

"C:/Programme/GnuWin32/bin/wget.exe" --append-output=c:/twitter/twitter.log --server-response --save-headers --header "Authorization: Basic BASE64 encoded username=password" http://api.twitter.com/1/friendships/create.xml?user_id=27016367 --output-document=c:/twitter/_follow_sent.txt

Same 401 error problem

No idea.

BTW, is there a command line useable software handling the oauth problem, basic authentification will turned off August 16th?

[edited by: phranque at 7:27 am (utc) on Jul 14, 2010]
[edit reason] unlink/de-obscure urls [/edit]

 

chorny




msg:4169873
 8:50 am on Jul 14, 2010 (gmt 0)

There are many modules for Twitter on CPAN. Like Net::Twitter [search.cpan.org], Net::Twitter::OAuth [search.cpan.org], Net::Twitter::Lite [search.cpan.org]. There are several ready Twitter clients in Perl, but I don't remember their names.

jetteroheller




msg:4169877
 9:11 am on Jul 14, 2010 (gmt 0)

My biggest problem, I am stuck with an very old version of Perl, because of using MSIE as GUI.

At a perl update, many years ago, there had been problems with the GUI updates. I tried for days, but I was not able to solve the GUI update problem with the new version.

The problem was, no GUI updates while PERL was working. So there was my work progress indicator not visible, while the system was on an 1 hour job. So I became stuck with the old version.

So I hoped for an easy way with an external software, where I can use a command line batch and pass all parameters.

tangor




msg:4169883
 9:31 am on Jul 14, 2010 (gmt 0)

Hate to be the wet blanket, and probably does not apply in this case if Tweets does not forbid, but I 403 Wget and I suspect quite a few other sites do as well.

chorny




msg:4170099
 5:02 pm on Jul 14, 2010 (gmt 0)

You can use several versions of Perl at once, or even package your program into .exe with PAR.

janharders




msg:4170132
 6:11 pm on Jul 14, 2010 (gmt 0)


You can use several versions of Perl at once, or even package your program into .exe with PAR.


Yeah, try installing both versions. PAR is probably a no-go for a web environment because I've always found it slow to start.

But generally: why not tackle the real problem: different versions of perl making problems. Maybe you'd like to explain those problems and the involvment of MSIE. I've never heard of serious problems with different perl versions before, so it might just be a small thing. That'd definetly make your life alot easier... using wget from perl when you should have LWP at your disposal is unncessary painful.

jetteroheller




msg:4170168
 7:49 pm on Jul 14, 2010 (gmt 0)

Maybe you'd like to explain those problems and the involvment of MSIE


My software runs under windows as a *.hta = Hyper Text Aplication

<html>
<head>
<title>My CMS</title>

<HTA:APPLICATION ID="oHTA"
applicationname="WDS Start"
icon=../pic/wds.ico
scroll=no
singleInstance=yes
windowstate=maximize />

<body scroll=no>
<br>
<br>
loading domain list
</center>

<script language=PerlScript>

use strict "vars";
use strict "refs";
use strict "subs";
use Win32::Shell;

&init();


All the GUI is in HTML.

With <.....OnClick=SubroutineWritteninPerl(4,4)>
There is the interaction between the HTML GUI and the
Perl software.

For longer tasks, I made a progress dislay,
showing the progress of the job.

The older Perl version shows the update of the HTML when ever I want it, the new version (about 2002) only when the job is finished and the program has to wait for the next user interaction.

chorny




msg:4170229
 10:13 pm on Jul 14, 2010 (gmt 0)

The older Perl version shows the update of the HTML when ever I want it, the new version (about 2002) only when the job is finished and the program has to wait for the next user interaction.


I guess by new you mean 5.8 and by older - 5.6. This may mean interaction with new Perl 5.8 idea - PerlIO. You may use binmode to change PerlIO behavior. Also you may submit a bug report to vendor - ActiveState.

jetteroheller




msg:4170369
 4:16 am on Jul 15, 2010 (gmt 0)

I am using

Perl APi522e.exe 5371 KB Nov 10th 1999

I described the problem at this time at th ActiveState forum for perl, filled bug reports, but no reaction.

I had the feeling, I am the only one using MSIE as the GUI for Perl

janharders




msg:4170595
 11:17 am on Jul 15, 2010 (gmt 0)

It might just be a buffering-issue, try adding
$|++;
to the script (before you output stuff, of course) to disable output buffering.

If that's not it, it might be a rendering-thing with MSIE, but that shouldn't change based on perl versions.

physics




msg:4171052
 8:55 pm on Jul 15, 2010 (gmt 0)

Did you try changing your useragent?

‘-U agent-string’
‘--user-agent=agent-string’
Identify as agent-string to the http server.

The http protocol allows the clients to identify themselves using a User-Agent header field. This enables distinguishing the www software, usually for statistical purposes or for tracing of protocol violations. Wget normally identifies as ‘Wget/version’, version being the current version number of Wget.

physics




msg:4171062
 9:07 pm on Jul 15, 2010 (gmt 0)

You might also want to check out this IBM article

"Cultured Perl: Practical Twitter with Perl
Learn to use the CPAN Net::Twitter module to access the Twitter API from Perl
"
[ibm.com]

jetteroheller




msg:4171080
 9:30 pm on Jul 15, 2010 (gmt 0)

You might also want to check out this IBM article


Thanks, but the examples are only with basic authentication.

Basic authentification will be tunred off by August 16th

My Perl software can actual use the API Twitter interface for all prupose where no authentification is required.

My only problem is the oAuth.

phranque




msg:4171097
 9:57 pm on Jul 15, 2010 (gmt 0)

there are perl/oauth examples linked from Twitter API Wiki / OAuth Examples [apiwiki.twitter.com].

jetteroheller




msg:4172341
 8:27 am on Jul 18, 2010 (gmt 0)

Did you try changing your useragent?

‘-U agent-string’
‘--user-agent=agent-string’
Identify as agent-string to the http server.


The problem was Twitter accepts only POST for friendship create.
The POST ist empty.

So the WGET parameter

--post-data=

solved the problem, but only until August 16th when basic authentification is turned off

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Perl Server Side CGI Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved