PHP code example of picturae / genealogy

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

    

picturae / genealogy example snippets


$client = new \Picturae\Genealogy\Client('api-key');

// Get a deed
$deed = $client->getDeed($id);
$person = $client->getPerson($id);
$register = $client->getRegister($id);

// Get a result list of deeds
// all parameters are optional
$deed = $client->getDeeds([
    'q' => 'something', // search query
    'rows' => 100,      // amount of rows to return
    'page' => 1,        // page to return
    'facetFields' => [  // facet's to return
        'search_s_place'
    ],
    'fq' => [
        'search_s_place: "Amsterdam"' // apply filter query
    ],
    'sort' => 'search_s_place asc'   // sort result set (default by relevance)
]);

// Get a result list of registers
// all parameters are optional
$deed = $client->getRegisters([
    'q' => 'something', // search query
    'rows' => 100,      // amount of rows to return
    'page' => 1,        // page to return
    'facetFields' => [  // facet's to return
        'search_s_place'
    ],
    'fq' => [
        'search_s_place: "Amsterdam"' // apply filter query
    ],
    'sort' => 'search_s_place asc'   // sort result set (default by relevance)
]);

// Get a result list of persons
// all parameters are optional
$deed = $client->getPersons([
    'q' => 'something', // search query
    'rows' => 100,      // amount of rows to return
    'page' => 1,        // page to return
    'facetFields' => [  // facet's to return
        'search_s_place'
    ],
    'fq' => [
        'search_s_place: "Amsterdam"' // apply filter query
    ],
    'sort' => 'search_s_place asc'   // sort result set (default by relevance)
]);


// If you do not provide a url the current url is used
$url = new \Picturae\Genealogy\URL();

// Check if we are on a permalink of a deed
if ($url->isDeedDetail()) {
    
    // Get the id for the deed from the URL
    $id = $url->getDeedUUID();

    // Instantiate the client with your API key
    $client = new \Picturae\Genealogy\Client('api-key');

    // Fetch the deed
    $deed = $client->getDeed($id);

    // Check if the deed is returned
    if (!empty($deed) {
        
        // Add your logic for the fallback
        // e.g add opengraph tags for facebook / twitter
        // or provide a html fallback

    }
}