API:Sprachrücklinks

From mediawiki.org
This page is a translated version of the page API:Langbacklinks and the translation is 100% complete.
MediaWiki Version:
1.18

GET-Abfrage um alle Seiten zu finden, die auf den angegebenen Sprachlink verlinken.

API-Dokumentation


(main | query | langbacklinks)
  • This module requires read rights.
  • This module can be used as a generator.
  • Source: MediaWiki
  • License: GPL-2.0-or-later

Find all pages that link to the given language link.

Can be used to find all links with a language code, or all links to a title (with a given language). Using neither parameter is effectively "all language links".

Note that this may not consider language links added by extensions.

Specific parameters:
Other general parameters are available.
lbllang

Language for the language link.

lbltitle

Language link to search for. Must be used with lbllang.

lblcontinue

When more results are available, use this to continue. More detailed information on how to continue queries can be found on mediawiki.org.

lbllimit

How many total pages to return.

Type: integer or max
The value must be between 1 and 500.
Default: 10
lblprop

Which properties to get:

lllang
Adds the language code of the language link.
lltitle
Adds the title of the language link.
Values (separate with | or alternative): lllang, lltitle
Default: (empty)
lbldir

The direction in which to list.

One of the following values: ascending, descending
Default: ascending

Beispiel

GET-Abfrage

Erhält Seiten, die auf einen bestimmten Sprachlink verlinken.


Antwort

{
    "batchcomplete": "",
    "query": {
        "langbacklinks": []
    }
}

Beispielcode

Python

#!/usr/bin/python3

"""
    langbacklinks.py
    MediaWiki API Demos
    Demo of `Langbacklinks` module: Get pages linking to a given language link
    MIT License
"""

import requests

S = requests.Session()

URL = "https://en.wikipedia.org/w/api.php"

PARAMS = {
    "action": "query",
    "list": "langbacklinks",
    "lbltitle": "Test",
    "lbllang": "fr",
    "format": "json"
}

R = S.get(url=URL, params=PARAMS)
DATA = R.json()

print(DATA)

PHP

<?php

/*
    langbacklinks.php
    MediaWiki API Demos
    Demo of `Langbacklinks` module: Get pages linking to a given language link
    MIT License
*/

$endPoint = "https://en.wikipedia.org/w/api.php";
$params = [
    "action" => "query",
    "list" => "langbacklinks",
    "lbltitle" => "Test",
    "lbllang" => "fr",
    "format" => "json"
];

$url = $endPoint . "?" . http_build_query( $params );

$ch = curl_init( $url );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
$output = curl_exec( $ch );
curl_close( $ch );

$result = json_decode( $output, true );
var_dump( $result );

JavaScript

/*
    langbacklinks.js
    MediaWiki API Demos
    Demo of `Langbacklinks` module: Get pages linking to a given language link
    MIT License
*/

var url = "https://en.wikipedia.org/w/api.php"; 

var params = {
    action: "query",
    list: "langbacklinks",
    lbltitle: "Test",
    lbllang: "fr",
    format: "json"
};

url = url + "?origin=*";
Object.keys(params).forEach(function(key){url += "&" + key + "=" + params[key];});

fetch(url)
    .then(function(response){return response.json();})
    .then(function(response) {console.log(response);})
    .catch(function(error){console.log(error);});

MediaWiki JS

/*
	langbacklinks.js
	MediaWiki API Demos
	Demo of `Langbacklinks` module: Get pages linking to a given language link
	MIT License
*/

var params = {
		action: 'query',
		list: 'langbacklinks',
		lbltitle: 'Test',
		lbllang: 'fr',
		format: 'json'
	},
	api = new mw.Api();

api.get( params ).done( function ( data ) {
	console.log( data );
} );

Mögliche Fehler

Code Info
missingparam Der Parameter lang muss gesetzt werden.

Parameterhistorie

  • v1.20: dir eingeführt

Zusätzliche Anmerkungen

  • Dieses Modul kann genutzt werden, um alle Seiten zu finden, die auf den gegebenen Sprachlink verlinken. Es findet alle Links, die einen Sprachcode nutzen oder alle Links auf einen bestimmten Titel (in einer bestimmten Sprache). Wenn keiner der Parameter genutzt wird, entspricht dies All Language Links.

Siehe auch

  • API:Links - Gibt alle Links von den angegebenen Seiten aus.
  • API:Sprachlinks - Erhält eine Liste aller Sprachlinks von den angegebenen Seiten auf andere Sprachen.