Skip to content

Latest commit

 

History

History
40 lines (27 loc) · 631 Bytes

readme.md

File metadata and controls

40 lines (27 loc) · 631 Bytes

Wikipedia

Installation

Begin by installing this package through Composer.

{
    "require": {
        "casinelli/wikipedia": "dev-master"
    }
}

Usage

Retrieve page extract

$wikipedia = new \Casinelli\Wikipedia\Wikipedia;

return $wikipedia->search("Rome")->getSentences(5);

Same with QueryBuilder

$qb = new \Casinelli\Wikipedia\QueryBuilder;

$qb->setFormat("php");
$qb->setTitles("Singapore");
$qb->setExtractsSentences(3);
$qb->setExtractsPlainText(true);

$response = unserialize( $qb->fetch() );

$page = reset( $response["query"]["pages"] );

return $page["extract"];