Skip Menu |
 

This queue is for tickets about the MediaWiki-API CPAN distribution.

Report information
The Basics
Id: 133452
Status: resolved
Priority: 0/
Queue: MediaWiki-API

People
Owner: Nobody in particular
Requestors: NATARAJ [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: 0.50



Subject: [PATCH] Wikipedia API does not work with http anymore
Download (untitled) / with headers
text/plain 368b
Hi! Wikipedia API stopped working with http some time ago. Examples from documentation do not work any more. One should change http:// to https:// to make it work again. And it would take some effort to figure out that this change is needed. So I would suggest to change http:// to https:// in examples in the pod documentation. Patch that does this is attached.
Subject: http_to_https_fix.diff
diff -ur MediaWiki-API-0.41.orig/lib/MediaWiki/API.pm MediaWiki-API-0.41/lib/MediaWiki/API.pm --- MediaWiki-API-0.41.orig/lib/MediaWiki/API.pm 2015-11-13 23:26:26.000000000 +0300 +++ MediaWiki-API-0.41/lib/MediaWiki/API.pm 2020-10-01 12:51:01.686341289 +0300 @@ -38,7 +38,7 @@ =head1 NAME -MediaWiki::API - Provides a Perl interface to the MediaWiki API (http://www.mediawiki.org/wiki/API) +MediaWiki::API - Provides a Perl interface to the MediaWiki API (https://www.mediawiki.org/wiki/API) =head1 VERSION @@ -50,12 +50,12 @@ =head1 SYNOPSIS -This module provides an interface between Perl and the MediaWiki API (http://www.mediawiki.org/wiki/API) allowing creation of scripts to automate editing and extraction of data from MediaWiki driven sites like Wikipedia. +This module provides an interface between Perl and the MediaWiki API (https://www.mediawiki.org/wiki/API) allowing creation of scripts to automate editing and extraction of data from MediaWiki driven sites like Wikipedia. use MediaWiki::API; my $mw = MediaWiki::API->new(); - $mw->{config}->{api_url} = 'http://en.wikipedia.org/w/api.php'; + $mw->{config}->{api_url} = 'https://en.wikipedia.org/w/api.php'; # log in to the wiki $mw->login( { lgname => 'username', lgpassword => 'password' } ) @@ -88,7 +88,7 @@ Returns a MediaWiki API object. You can pass a config as a hashref when calling new, or set the configuration later. When creating a new object, defaults for max lag and retries are set. - my $mw = MediaWiki::API->new( { api_url => 'http://en.wikipedia.org/w/api.php' } ); + my $mw = MediaWiki::API->new( { api_url => 'https://en.wikipedia.org/w/api.php' } ); Configuration options are @@ -98,7 +98,7 @@ =item * files_url = 'Base url for files'; (needed if the api returns a relative URL for images like /images/a/picture.jpg) -=item * upload_url = 'http://en.wikipedia.org/wiki/Special:Upload'; (path to the upload special page which is required if you want to upload images) +=item * upload_url = 'https://en.wikipedia.org/wiki/Special:Upload'; (path to the upload special page which is required if you want to upload images) =item * on_error = Function reference to call if an error occurs in the module. @@ -110,7 +110,7 @@ =item * retry_delay = Integer value in seconds; The amount of time to wait before retrying a request if an HTTP error or JSON decoding error occurs. -=item * max_lag = Integer value in seconds; Wikipedia runs on a database cluster and as such high edit rates cause the slave servers to lag. If this config option is set then if the lag is more then the value of max_lag, the api will wait before retrying the request. 5 is a recommended value. More information about this subject can be found at http://www.mediawiki.org/wiki/Manual:Maxlag_parameter. note the config option includes an underscore so match the naming scheme of the other configuration options. +=item * max_lag = Integer value in seconds; Wikipedia runs on a database cluster and as such high edit rates cause the slave servers to lag. If this config option is set then if the lag is more then the value of max_lag, the api will wait before retrying the request. 5 is a recommended value. More information about this subject can be found at https://www.mediawiki.org/wiki/Manual:Maxlag_parameter. note the config option includes an underscore so match the naming scheme of the other configuration options. =item * max_lag_delay = Integer value in seconds; This configuration option specified the delay to wait before retrying a request when the server has reported a lag more than the value of max_lag. This defaults to 5 if using the max_lag configuration option. @@ -226,9 +226,9 @@ =head2 MediaWiki::API->login( $query_hashref ) -Logs in to a MediaWiki. Parameters are those used by the MediaWiki API (http://www.mediawiki.org/wiki/API:Login). Returns a hashref with some login details, or undef on login failure. If Mediawiki sends requests a LoginToken the login is attempted again, but with the token sent from the initial login. Errors are stored in MediaWiki::API->{error}->{code} and MediaWiki::API->{error}->{details}. +Logs in to a MediaWiki. Parameters are those used by the MediaWiki API (https://www.mediawiki.org/wiki/API:Login). Returns a hashref with some login details, or undef on login failure. If Mediawiki sends requests a LoginToken the login is attempted again, but with the token sent from the initial login. Errors are stored in MediaWiki::API->{error}->{code} and MediaWiki::API->{error}->{details}. - my $mw = MediaWiki::API->new( { api_url => 'http://en.wikipedia.org/w/api.php' } ); + my $mw = MediaWiki::API->new( { api_url => 'https://en.wikipedia.org/w/api.php' } ); #log in to the wiki $mw->login( {lgname => 'username', lgpassword => 'password' } ) @@ -264,7 +264,7 @@ =head2 MediaWiki::API->api( $query_hashref, $options_hashref ) -Call the MediaWiki API interface. Parameters are passed as a hashref which are described on the MediaWiki API page (http://www.mediawiki.org/wiki/API). returns a hashref with the results of the call or undef on failure with the error code and details stored in MediaWiki::API->{error}->{code} and MediaWiki::API->{error}->{details}. MediaWiki::API uses the LWP::UserAgent module to send the http requests to the MediaWiki API. After any API call, the response object returned by LWP::UserAgent is available in $mw->{response}. This function will NOT modify the input query_hashref in any way. +Call the MediaWiki API interface. Parameters are passed as a hashref which are described on the MediaWiki API page (https://www.mediawiki.org/wiki/API). returns a hashref with the results of the call or undef on failure with the error code and details stored in MediaWiki::API->{error}->{code} and MediaWiki::API->{error}->{details}. MediaWiki::API uses the LWP::UserAgent module to send the http requests to the MediaWiki API. After any API call, the response object returned by LWP::UserAgent is available in $mw->{response}. This function will NOT modify the input query_hashref in any way. binmode STDOUT, ':utf8'; @@ -290,7 +290,7 @@ MediaWiki's API uses UTF-8 and any 8 bit character string parameters are encoded automatically by the API call. If your parameters are already in UTF-8 this will be detected and the encoding will be skipped. If your parameters for some reason contain UTF-8 data but no UTF-8 flag is set (i.e. you did not use the "use utf8;" pragma) you should prevent re-encoding by passing an option skip_encoding => 1 in the $options_hash. For example: my $mw = MediaWiki::API->new(); - $mw->{config}->{api_url} = 'http://fr.wiktionary.org/w/api.php'; + $mw->{config}->{api_url} = 'https://fr.wiktionary.org/w/api.php'; my $query = {action => 'query', list => 'categorymembers', @@ -462,7 +462,7 @@ =head2 MediaWiki::API->edit( $query_hashref, $options_hashref ) -A helper function for doing edits using the MediaWiki API. Parameters are passed as a hashref which are described on the MediaWiki API editing page (http://www.mediawiki.org/wiki/API:Changing_wiki_content). Note that you need $wgEnableWriteAPI = true in your LocalSettings.php to use these features. This function will modify the input hashref. +A helper function for doing edits using the MediaWiki API. Parameters are passed as a hashref which are described on the MediaWiki API editing page (https://www.mediawiki.org/wiki/API:Changing_wiki_content). Note that you need $wgEnableWriteAPI = true in your LocalSettings.php to use these features. This function will modify the input hashref. Currently @@ -579,7 +579,7 @@ =back -Full information about these can be read on (http://www.mediawiki.org/wiki/API:Query_-_Properties#revisions_.2F_rv) +Full information about these can be read on (https://www.mediawiki.org/wiki/API:Query_-_Properties#revisions_.2F_rv) =cut @@ -600,7 +600,7 @@ =head2 MediaWiki::API->list( $query_hashref, $options_hashref ) -A helper function for getting lists using the MediaWiki API. Parameters are passed as a hashref which are described on the MediaWiki API editing page (http://www.mediawiki.org/wiki/API:Query_-_Lists). This function modifies the input query_hashref. +A helper function for getting lists using the MediaWiki API. Parameters are passed as a hashref which are described on the MediaWiki API editing page (https://www.mediawiki.org/wiki/API:Query_-_Lists). This function modifies the input query_hashref. This function will return a reference to an array of hashes or undef on failure. It handles getting lists of data from the MediaWiki api, continuing the request with another connection if needed. The options_hashref currently has three parameters: @@ -694,9 +694,9 @@ A function to upload files to a MediaWiki. This function does not use the MediaWiki API currently as support for file uploading is not yet implemented. Instead it uploads using the Special:Upload page, and as such an additional configuration value is needed. my $mw = MediaWiki::API->new( { - api_url => 'http://en.wikipedia.org/w/api.php' } ); + api_url => 'https://en.wikipedia.org/w/api.php' } ); # configure the special upload location. - $mw->{config}->{upload_url} = 'http://en.wikipedia.org/wiki/Special:Upload'; + $mw->{config}->{upload_url} = 'https://en.wikipedia.org/wiki/Special:Upload'; The upload function is then called as follows
thanks. This is included in v0.50


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.