How do I use PHP
to get the first paragraph of any article from Wikipedia through their MediaWiki API?
I am open to all suggestions. Most probably CURL
or XML
will come in handy.
How do I use PHP
to get the first paragraph of any article from Wikipedia through their MediaWiki API?
I am open to all suggestions. Most probably CURL
or XML
will come in handy.
You can use the API as so:
This will return an xml file with structure:
Note the variables:
page=Article_Title_Goes_Here
format=xml
prop=text
I would use
file_get_contents('http://wikipedia.com/'.$rest_of_url)
Then just use string parsing to select everything form
to
http://php.net/manual/en/function.substr.php