Hello,
I am writing a Java program to extract the abstract of the wikipedia page
given the title of the wikipedia page. I have done some research and found
out that the abstract with be in rvsection=0
So for example if I want the abstract of 'Eiffel Tower" wiki page then I am
querying using the api in the following way.
http://en.wikipedia.org/w/api.php?action=query&prop=revisions&titles=Eiffel…
and parse the XML data which we get and take the wikitext in the tag <rev
xml:space="preserve"> which represents the abstract of the wikipedia page.
But this wiki text also contains the infobox data which I do not need. I
would like to know if there is anyway in which I can remove the infobox data
and get only the wikitext related to the page's abstract Or if there is any
alternative method by which I can get the abstract of the page directly.
Looking forward to your help.
Thanks in Advance
Aditya Uppu
When list=allusers is used with auactiveusers, a property 'recenteditcount'
is returned in the result. In bug 67301[1] it was pointed out that this
property is including various other logged actions, and so should really be
named something like "recentactions".
Gerrit change 130093,[2] merged today, adds the "recentactions" result
property. "recenteditcount" is also returned for backwards compatability,
but will be removed at some point during the MediaWiki 1.25 development
cycle.
Any clients using this property should be updated to use the new property
name. The new property will be available on WMF wikis with 1.24wmf12, see
https://www.mediawiki.org/wiki/MediaWiki_1.24/Roadmap for the schedule.
[1]: https://bugzilla.wikimedia.org/show_bug.cgi?id=67301
[2]: https://gerrit.wikimedia.org/r/#/c/130093/
--
Brad Jorsch (Anomie)
Software Engineer
Wikimedia Foundation
_______________________________________________
Mediawiki-api-announce mailing list
Mediawiki-api-announce(a)lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-api-announce
I try to auto-login mediawiki by API login,but didn't know how to do.Since I already used login api get "success" status on sandbox, I think maybe I do something wrong on set cookie.Get token and login api has been revamped in version 1.27 of MediaWiki,I can't find any example code work on 1.28.Thanks for all responses and suggestion. I've been stuck for so long. I really appreciate some help here. Thanks.
Here's my code,but didn't get login token properly.
System Info:
Software Version
MediaWiki 1.28.2
PHP 5.6.30
MariaDB 10.1.21
<?php
namespace mediawiki;
// Start session
session_start();
/**
* How to log in mediawiki using PHP cURL?
* -------------------------------------------------
*/
//set login username password which already in your mediawiki database
$username = 'abc';
$password = '123';
//setup url
$Root = 'localhost/mediawiki';
$API_Location = "${Root}/api.php";
//setup cookie
$CookieFilePath = tempnam("/tmp", "TMP0");
$expire = 60*60*24*14 + time();
$CookiePrefix = 'theprefix';
$Domain = 'localhost';
// set variables to use in curl_setopts
$PostFields = "action=query&meta=tokens&type=login&format=json";
// first http post to sign in to MediaWiki
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "$API_Location");
curl_setopt($ch, CURLOPT_TIMEOUT, 500);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/x-www-form-urlencoded',
'Content-Length: ' .strlen($PostFields))
);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "$PostFields");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_COOKIEJAR, $CookieFilePath);
curl_setopt($ch, CURLOPT_COOKIEFILE, $CookieFilePath);
$Result = curl_exec($ch);
if(curl_exec($ch) === false) echo '<br>Curl error: ' . curl_error($ch).'<br>';
curl_close($ch); // curl closed
$ResultSerialized = json_decode($Result,true);
$Token = $ResultSerialized["query"]["tokens"]["logintoken"];
// cookie must be set using session id from first response
$_SESSION["logintoken"]=$Token;
//How can I get sessionid?
$sessionid=session_id();
$_SESSION["sessionid"] =$sessionid;
setcookie("${CookiePrefix}_Session",$sessionid , $expire, '/', $Domain);
setcookie("${CookiePrefix}UserName",$username,$expire,'/',$Domain);
setcookie("${CookiePrefix}Token", $_SESSION["logintoken"], $expire, '/', $Domain);
// second http post to finish sign in
$ch = curl_init();
$PostFields="action=login&lgname=${username}&lgpassword=${password}&lgtoken=${Token}&format=json";
curl_setopt($ch, CURLOPT_URL, "$API_Location");
curl_setopt($ch, CURLOPT_TIMEOUT, 500);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/x-www-form-urlencoded',
'Content-Length: ' .strlen($PostFields))
);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "$PostFields");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_COOKIE, "${CookiePrefix}_session=$sessionid");
curl_setopt($ch, CURLOPT_COOKIEJAR, $CookieFilePath);
curl_setopt($ch, CURLOPT_COOKIEFILE, $CookieFilePath);
$Result = curl_exec($ch);
if(curl_exec($ch) === false) echo '<br>Curl error: ' . curl_error($ch).'<br>';
curl_close($ch); // curl closed
$ResultSerialized = json_decode($Result,true);
// set persistent cookies
//$LgToken = $ResultSerialized["query"]["tokens"]["logintoken"];
$LgUserID = $ResultSerialized["login"]["lguserid"];
$LgUserName = $ResultSerialized["login"]["lgusername"];
$lgstatus=$ResultSerialized["login"]["result"];
var_dump($lgstatus);
setcookie("${CookiePrefix}UserName", $LgUserName, $expire, '/', $Domain);
setcookie("${CookiePrefix}UserID", $LgUserID, $expire, '/', $Domain);
//setcookie("${CookiePrefix}Token", $Token, $expire, '/', $Domain);
// Delete cURL cookie
unlink($CookieFilePath);
?>
I also try to use clientlogin via postman, post request exactly like example on mediawiki.org/wiki/API:Login ,but result: "authmanager-authn-no-primary".
Reference:
stackoverflow.com/questions/14107523/how-do-i-log-into-mediawiki-using-php-…mediawiki.org/wiki/User:Krinkle/API_PHP_cURL_examplemediawiki.org/wiki/API:Login/de/1_Beispielmediawiki.org/wiki/API:Login
Dear all
I have one confusion and would be extremely grateful if some clarification
is offered.
https://en.wikipedia.org//w/api.php?action=query&format=xml&
prop=revisions&titles=Sachin_Tendulkar&rvprop=ids%7Ctimesta
mp%7Ccomment%7Cuser&rvlimit=30&rvdiffto=prev
This is a api request I prepared using mediawiki sandbox tool to get 30
sequential edits for the page Sachin Tendulkar. If you run the query in
your browser you will see a diff field for each edit
which probably is the difference between past and current edit. Here
revision content field is false
https://en.wikipedia.org//w/api.php?action=query&format=xml&
prop=revisions&titles=Sachin_Tendulkar&rvprop=ids%7Ctimesta
mp%7Ccomment%7Cuser%7Ccontent&rvlimit=30&rvdiffto=prev
This is the same request with content filed true
Now What I see is that for all 30 revision content field is more or less
same and right now I am not able to understand what is the reason for the
content field. If you know anything regarding this please let me know , I
am also trying to understand this field.
Regards
Soumya
Hi!
My name is Elisa and I'm trying to do a project with mediawiki and eclipse.
I have some questions about how to get the content of my page. I mean, I'm
making a wiki and I want to print the content in my eclipse project when I
need it. (It's a wiki about code).
How can I make the request?
Best,
Elisa
Most of the time, the ordering implied by revision ID number and the
ordering implied by revision timestamp are the same. Differences occur
mainly when revisions are imported from another wiki, however there may be
other situations that can cause this.
The database queries that were formerly used to handle the rvstartid and
rvendid parameters were found to be very inefficient.[1] As of Gerrit
change 349448,[2] these parameters are now equivalent to using the
timestamps of the corresponding revisions for rvstart and rvend.
This change should be deployed to WMF wikis with 1.30.0-wmf.1, see
https://www.mediawiki.org/wiki/MediaWiki_1.30/Roadmap for the schedule.
[1]: https://phabricator.wikimedia.org/T163495#3200490
[2]: https://gerrit.wikimedia.org/r/#/c/349448/
--
Brad Jorsch (Anomie)
Senior Software Engineer
Wikimedia Foundation
_______________________________________________
Mediawiki-api-announce mailing list
Mediawiki-api-announce(a)lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-api-announce
Hello,
I’m currently converting `action=ask&query=[[Category:Event]][[OnDate::<2017/05/03]] + etc` to use `action=askargs`.
So far I stripped away the double square brackets around Category:Event, and it gives back results.
`action=ask&conditions=Category:Event&printouts=NameOfEvent`
If I try to filter Category:Event by today’s date as above though, I get an error back, in all the following combination:
* `action=ask&conditions=Category:Event[[OnDate::<2017/05/03]]&printouts=NameOfEvent`
* `action=ask&conditions=Category:EventOnDate::<2017/05/03&printouts=NameOfEvent`
* `action=ask&conditions=Category:Event|OnDate::<2017/05/03&printouts=NameOfEvent`
* `action=ask&conditions=Category:Event&OnDate::<2017/05/03&printouts=NameOfEvent`
Is it possible to use any similar syntax and filter upfront pages based on properties?
The only reason why I am try to switch to askargs, is that, unlike ask, it has a query-continue-offset.
Thanks,
André
Hello,
This is just a friendly reminder that the page metadata end points
mentioned below will be completely removed on 2017-05-08. Please update
your clients if you are still using any of them.
Cheers,
Marko Obrovac, PhD
Senior Services Engineer
Wikimedia Foundation
On 23 February 2017 at 18:28, Petr Pchelko <ppchelko(a)wikimedia.org> wrote:
> Hello,
>
> Since the early days of REST API it provides two features that haven’t
> been widely used neither internally in the WMF nor by the community. Today
> in a clean-up pass over the API we have decided to deprecate and eventually
> remove those features to allow some long-needed refactorings and stability
> improvements of other, more important, endpoints.
>
> The first one is the ability to query metadata about the page via the
> `/page/title/{title}`~[1] endpoint. The metadata includes properties like
> the latest revision number of the page, user who have made the last edit,
> whether the page is a redirect and similar. The backend storage model used
> to power the feature is quite unique in the system and has a significant
> maintenance cost without providing a clear benefit to users.
>
> Another feature that’s never found it’s audience is the ability to get
> listings of revisions, titles and renders stored in RESTBase. These
> listings suffer from scaling issues and cannot work reliably with the data
> model we have.
>
> We have, hence, opted to remove these unused and complex endpoints until
> there is some actual need for this data in the REST API when we can design
> and implement them better. Here’s the list of endpoints that are now
> deprecated and will be removed on May, 1st 2017:
>
> • /page/title/
> • /page/title/{title}
> • /page/title/{title}/
> • /page/revision/
> • /page/revision/{revision}
>
> In case you are using them please switch to using the MediaWiki Action
> API. In case you need assistance or have questions, feel free to reply to
> this e-mail or contact the Wikimedia Services team~[2].
>
> Best regards,
> Petr Pchelko
> Software Engineer
> Wikimedia Foundation
>
> [1] https://en.wikipedia.org/api/rest_v1/#!/Page_content/get_
> page_title_title
> [2] https://www.mediawiki.org/wiki/Wikimedia_Services
>
>
> _______________________________________________
> Mediawiki-api-announce mailing list
> Mediawiki-api-announce(a)lists.wikimedia.org
> https://lists.wikimedia.org/mailman/listinfo/mediawiki-api-announce
>
Hi all,
not sure whether this is an API issue, or something to do with the way
coordinates are stored.
If you look at this query, you'll see that for some of the pages
coordinates are listed, for others they are not:
https://de.wikipedia.org/w/api.php?action=query&prop=coordinates&generator=…
However, quite a few pages do have coordinates on the corresponding
wikipedia page, e.g.
https://de.wikipedia.org/wiki/Cornia_Nou
Any ideas what that might be?
(As an aside, just in case it's related: How do coordinates end up in
Wikidata? I assume it's a bot? Presumably the bot uses the API? Some of the
above pages have got coordinates on the page, but not in Wikidata...)
Thanks!
Bjoern