【发布时间】:2016-04-10 20:18:36
【问题描述】:
问题
我有从 wikimedia API 获得的 JSON 格式的 JSON 内容。我想提取 [*] 这个下的数据。虽然在调用页面 id 之前我不知道,所以我不能在中间使用 pageid。我也不知道如何通过 astrics ( * )。我使用以下代码来获取数据,但出现错误。
非常感谢任何帮助或指导。
代码
$api_data->query->pages->revisions[0]->['*'];
JSON
stdClass Object
(
[batchcomplete] =>
[query] => stdClass Object
(
[pages] => stdClass Object
(
[27000] => stdClass Object
(
[pageid] => 27000
[ns] => 0
[title] => Patna
[revisions] => Array
(
[0] => stdClass Object
(
[contentformat] => text/x-wiki
[contentmodel] => wikitext
[*] => ==Understand==
The ancient name of Patna was 'Pataliputra' and it was the capital of the Maurya and Gupta empires. Located at the site where Patna is today, the ancient city of Patliputra, with a glorious period of history spanning a thousand years (500BC-400AD), saw the rise and fall of India's first major kingdoms.
Lying along the banks of the Ganges River, Patna is surrounded by important religious centers for the Buddhists, Sikhs and Jains. This city has been home to two great religions, Buddhism and Jainism, and myriad dynasties from ancient to modern times.
)
)
)
)
)
)
【问题讨论】:
-
$api_data->query->pages->revisions[0]->{'*'}; -
感谢您的帮助!!
标签: php json mediawiki wikipedia-api