Created
April 8, 2015 22:12
-
-
Save jimmyz/b34a2cf11d787a09665e to your computer and use it in GitHub Desktop.
Read the ancestry of a person
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require 'vendor/autoload.php'; | |
session_start(); | |
use Gedcomx\Extensions\FamilySearch\Rs\Client\FamilyTree\FamilyTreeStateFactory; | |
use Gedcomx\Rs\Client\Options\QueryParameter; | |
use Gedcomx\Rs\Client\PersonState; | |
use Gedcomx\Conclusion\Person; | |
// $personId = "KW4V-6T4"; // John Hannon | |
$personId = "KW4V-X9F"; //Jon Samsonite | |
// $personId = 'KW4V-6T7'; // Sheree Hannon | |
if(isset($_SESSION['fs_access_token'])){ | |
$accessToken = $_SESSION['fs_access_token']; | |
$stateFactory = new FamilyTreeStateFactory(); | |
$personState = $stateFactory | |
->newCollectionState("https://sandbox.familysearch.org/platform/collections/tree") //read the collection | |
->authenticateWithAccessToken($accessToken) //set the Access Token | |
->readPersonById($personId); //read the person | |
$queryParameter = QueryParameter::generations(8); | |
$ancestryState = $personState->readAncestry($queryParameter); | |
$persons = $ancestryState->getEntity()->getPersons(); | |
}else{ | |
echo "Error: No access token"; | |
exit; | |
} | |
?> | |
<html> | |
<head> | |
<title>Searching for Person John Hannon</title> | |
</head> | |
<body> | |
<?php foreach($persons as $person): | |
?> | |
<table> | |
<tr> | |
<th>Field</th> | |
<th>Value</th> | |
</tr> | |
<tr> | |
<td>Full Name:</td> | |
<td><?= $person->getDisplayExtension()->getName(); ?></td> | |
</tr> | |
<tr> | |
<td>Birth Date:</td> | |
<td><?= $person->getDisplayExtension()->getBirthDate(); ?></td> | |
</tr> | |
<tr> | |
<td>Death Date:</td> | |
<td><?= $person->getDisplayExtension()->getDeathDate(); ?></td> | |
</tr> | |
</table> | |
<?php endforeach; ?> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment