Mediawiki JSON 响应:正在检索每个类别成员的缩略图
Mediawiki JSON response: retrieving thumbnail of each category members
我正在使用 Mediawiki 创建一个项目,并在一个类别中添加了 150 个成员。我需要检索 JSON 和每个类别成员的缩略图,以便在我的应用程序中使用它。
但不幸的是,我无法检索该类别中所有类别成员的缩略图。只有 48 位成员显示 url 类别中的缩略图,即使图像已正确添加到网站中,就像为这 48 位成员添加的一样。
我做错了什么导致我在 JSON 中的查询响应中出现此错误。
查询示例:
http://example.org/api.php?gcmlimit=max&action=query&gcmtitle=Category%3AName&pilimit=max&prop=pageimages&pithumbsize=100&generator=categorymembers&format=json&continue=
URL 以上只是显示我用于检索 json 文件响应的查询的示例。
提前致谢
这个解决方案对我有用,我成功了。
您可以使用 pageImages 查询 JSON 增加缩略图 url 检索的限制
您将必须转到安装此扩展程序的扩展程序。
其中包含文件夹中会有一个名为 APIQueryPageImages.php 的 php 文件。
在php文件夹里面有一个函数"getAllowedParams()"将里面定义的Values改成需要的值,如下图:
public function getAllowedParams() {
return array(
'prop' => array(
ApiBase::PARAM_TYPE => array( 'thumbnail', 'name', 'original' ),
ApiBase::PARAM_ISMULTI => true,
ApiBase::PARAM_DFLT => 'thumbnail|name',
),
'thumbsize' => array(
ApiBase::PARAM_TYPE => 'integer',
APiBase::PARAM_DFLT => 50,
),
'limit' => array(
ApiBase::PARAM_DFLT => 1,
ApiBase::PARAM_TYPE => 'limit',
ApiBase::PARAM_MIN => 1,
ApiBase::PARAM_MAX => 500, //Here you can change the limit of value for user which was by default "50"
ApiBase::PARAM_MAX2 => 600, ////Here you change the limit of value for bots which was by default "100"
),
'continue' => array(
ApiBase::PARAM_TYPE => 'integer',
/** @todo Once support for MediaWiki < 1.25 is dropped, just use ApiBase::PARAM_HELP_MSG directly */
defined( 'ApiBase::PARAM_HELP_MSG' ) ? ApiBase::PARAM_HELP_MSG : '' => 'api-help-param-continue',
),
);
}
我正在使用 Mediawiki 创建一个项目,并在一个类别中添加了 150 个成员。我需要检索 JSON 和每个类别成员的缩略图,以便在我的应用程序中使用它。
但不幸的是,我无法检索该类别中所有类别成员的缩略图。只有 48 位成员显示 url 类别中的缩略图,即使图像已正确添加到网站中,就像为这 48 位成员添加的一样。
我做错了什么导致我在 JSON 中的查询响应中出现此错误。
查询示例:
http://example.org/api.php?gcmlimit=max&action=query&gcmtitle=Category%3AName&pilimit=max&prop=pageimages&pithumbsize=100&generator=categorymembers&format=json&continue=
URL 以上只是显示我用于检索 json 文件响应的查询的示例。
提前致谢
这个解决方案对我有用,我成功了。
您可以使用 pageImages 查询 JSON 增加缩略图 url 检索的限制
您将必须转到安装此扩展程序的扩展程序。
其中包含文件夹中会有一个名为 APIQueryPageImages.php 的 php 文件。 在php文件夹里面有一个函数"getAllowedParams()"将里面定义的Values改成需要的值,如下图:
public function getAllowedParams() {
return array(
'prop' => array(
ApiBase::PARAM_TYPE => array( 'thumbnail', 'name', 'original' ),
ApiBase::PARAM_ISMULTI => true,
ApiBase::PARAM_DFLT => 'thumbnail|name',
),
'thumbsize' => array(
ApiBase::PARAM_TYPE => 'integer',
APiBase::PARAM_DFLT => 50,
),
'limit' => array(
ApiBase::PARAM_DFLT => 1,
ApiBase::PARAM_TYPE => 'limit',
ApiBase::PARAM_MIN => 1,
ApiBase::PARAM_MAX => 500, //Here you can change the limit of value for user which was by default "50"
ApiBase::PARAM_MAX2 => 600, ////Here you change the limit of value for bots which was by default "100"
),
'continue' => array(
ApiBase::PARAM_TYPE => 'integer',
/** @todo Once support for MediaWiki < 1.25 is dropped, just use ApiBase::PARAM_HELP_MSG directly */
defined( 'ApiBase::PARAM_HELP_MSG' ) ? ApiBase::PARAM_HELP_MSG : '' => 'api-help-param-continue',
),
);
}