8
protocol => 'https',
9 host => 'wiki.eng.xxx.com',
This is where you're going wrong. You can see from the carp
Error code: 2 at bot.pl line 14
500 Can't connect to https:80 (Bad hostname 'https') : error occurred
when accessing
http://https/host/api.php after 6 attempt(s) at bot.pl
line 14
that it is trying to contact "http://https/host/api.php" which is... not
valid. At all. You have to set protocol, host and path properly.
I was puzzled when the script ended up connecting to
http://https/host/api.php. My host, protocol and path seem to be
correct. So, if I intend to connect to
https://wiki.eng.xx.com/foo/bar
is this how I should assign my variables?
my $bot = MediaWiki::Bot->new(
useragent => 'MediaWiki::Bot 2.3.1 (User:Mike.lifeguard)',
assert => 'bot',
protocol => 'https',
host => 'wiki.eng.xxx.com',
path => 'foo/bar',
);
$bot->set_wiki(
protocol => 'https',
host => 'wiki.eng.xxx.com',
path => 'foo/bar',
);
$bot->login(
{
username => 'user',
password => 'passwd',
},
) or die "Login failed";
Since the host, path and protocol were all initialized when when
initializing $bot, is it necessary to call $bot->set_wiki()
subsequently? That step sounds redundant to me..
I can't tell what mistake you made without the
actual code and output.
The code I pasted earlier is exactly what I used (with the exception
of replacing the username/password and xx with valid strings).
I tried
setting usagent to 'MediaWiki::Bot 2.3.1
(User:Mike.lifeguard)' as well, but it didn't help.
The useragent is totally unrelated, and you don't need to set it at all.
As evidenced by the above, the default is probably better than what most
people will set it to.
And I have to ask... you have MediaWiki::Bot 3.0? You checked it out
from SVN yourself? Because the code you've copied is written for 3.0...
if you don't have 3.0 then you're likely going to have issues.
As Jimmy pointed out, I download whatever was available on CPAN and it
turned out to be version 3.0.
thanks,
ravi