PHP code example of ppp / wikidataquery-api

1. Go to this page and download the library: Download ppp/wikidataquery-api 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/ */

    

ppp / wikidataquery-api example snippets


// Load everything
P connection
$api = new WikidataQueryApi( 'https://wdq.wmflabs.org/api' );

// Build helper tools
$wikidataQueryFactory = new WikidataQueryFactory( $api );
$simpleQueryService = $wikidataQueryFactory->newSimpleQueryService();

//Do a query that returns a list of ItemId
//This query finds all the children (P40) of Charlemagne (Q3044)
$itemIds = $simpleQueryService->doQuery(
	new ClaimQuery( new PropertyId( 'P17' ), new ItemId( 'Q3044' ) );
);