I want to return the title, first five sentences and the main image from a random wikipedia article.
Is it possible to do this in a single call?
I'm using PHP.
First call works fine and gets the title and first five sentences.
Second call works and gets the images.
Third call is my attempt to combine the first two calls and it returns the images but throws a message:
["warnings"] => array(1) { ["main"] => array(1) { ["*"] => string(67) "Unrecognized parameters: explaintext, exsectionformat, exsentences."
First ...
$url='.php?action=query&prop=extracts&exsentences=5&explaintext=&exsectionformat=plain&format=json&pageids='.$item->id;
$x=json_decode(file_get_contents($url), true); ```
dump($x);
Second...
$url='.php?action=query&prop=pageimages&pithumbsize=200&format=json&pageids='.$item->id;
$x=json_decode(file_get_contents($url), true);
dump($x);
Third...
$url='.php?action=query&prop=extracts&exsentences=5&explaintext=&exsectionformat=plain&format=json&prop=pageimages&pithumbsize=200&pageids='.$item->id;
$x=json_decode(file_get_contents($url), true); ```
dump($x);
I want to return the title, first five sentences and the main image from a random wikipedia article.
Is it possible to do this in a single call?
I'm using PHP.
First call works fine and gets the title and first five sentences.
Second call works and gets the images.
Third call is my attempt to combine the first two calls and it returns the images but throws a message:
["warnings"] => array(1) { ["main"] => array(1) { ["*"] => string(67) "Unrecognized parameters: explaintext, exsectionformat, exsentences."
First ...
$url='https://en.wikipedia.org/w/api.php?action=query&prop=extracts&exsentences=5&explaintext=&exsectionformat=plain&format=json&pageids='.$item->id;
$x=json_decode(file_get_contents($url), true); ```
dump($x);
Second...
$url='https://en.wikipedia.org/w/api.php?action=query&prop=pageimages&pithumbsize=200&format=json&pageids='.$item->id;
$x=json_decode(file_get_contents($url), true);
dump($x);
Third...
$url='https://en.wikipedia.org/w/api.php?action=query&prop=extracts&exsentences=5&explaintext=&exsectionformat=plain&format=json&prop=pageimages&pithumbsize=200&pageids='.$item->id;
$x=json_decode(file_get_contents($url), true); ```
dump($x);
This is the url I used to get the info I needed. The key, I think, is the chaining of '&prop=extracts|pageimages|info' in the request.
$url='https://en.wikipedia.org/w/api.php?action=query&format=json&prop=extracts|pageimages|info&inprop=url&exintro=1&explaintext=1&exsentences=5&piprop=original&pageids=' . $item->id;
$x=json_decode(file_get_contents($url), true);
dump($x);