API:Langbacklinks
This page is part of the MediaWiki Action API documentation. |
เวอร์ชันมีเดียวิกิ: | ≥ 1.18 |
GET request to find all pages that link to the given language link.
API documentation
ตัวอย่าง
GET request
Get pages linking to a given language link.
api.php? action=query& format=json& list=langbacklinks& lbltitle=Test& lbllang=fr [ลองใช้ในกระบะทรายเอพีไอ]
Response
{
"batchcomplete": "",
"query": {
"langbacklinks": []
}
}
รหัสตัวอย่าง
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 );
} );
ข้อบกพร่อง (error) ที่อาจเกิด
Code | Info |
---|---|
missingparam | The lang parameter must be set. |
ประวัติพารามิเตอร์ (Parameter history)
- v1.20: เปิดตัว
dir
บันทึกเพิ่มเติม
- This module can be used to find all pages that link to the given language link. It finds all links using a language code, or all links to a given title (with a given language). Using neither parameter is effectively
All Language Links
.
ดูเพิ่ม
- API:Links - Returns all links from the given pages.
- API:Langlinks - Gets a list of all language links from the provided pages to other languages.