PHP code example of ekendra / wikipedia
1. Go to this page and download the library: Download ekendra/wikipedia library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
ekendra / wikipedia example snippets
$wikipedia = new \Ekendra\Wikipedia\Wikipedia;
return $wikipedia->search("Rome")->getSentences(5);
$qb = new \Ekendra\Wikipedia\QueryBuilder;
$qb->setFormat("php");
$qb->setTitles("Nepal");
$qb->setExtractsSentences(3);
$qb->setExtractsPlainText(true);
$response = unserialize( $qb->fetch() );
$page = reset( $response["query"]["pages"] );
return $page["extract"];