</form>
  <br>

<?php 
if ($personId) {
    // First we make a request to the API for the person and save the response
    $personResponse = $client->familytree()->readPersonById($personId);
    // Check for errors
    if ($personResponse->hasError()) {
        handleErrors($personResponse);
    } else {
        // Then we get the person from the response
        $ancestryResponse = $personResponse->readAncestry(Gedcomx\Rs\Client\Options\QueryParameter::generations('4'));
        // Check for errors
        if ($ancestryResponse->hasError()) {
            handleErrors($ancestryResponse);
        } else {
            // There are two ways we can traverse the tree. The first is recursively
            // via a tree structure. The second is by iterating over the Ahnentafel numbers.
            $tree = $ancestryResponse->getTree();
            ?>
          <h2>Recursive</h2>
          <p>This list of ancestors was generated by recursively traversing the
          tree structure. It should match the iterative list below.</p>
          <table class="table">
            <tr>
              <th>Ahnentafel #</th>
              <th>ID</th>
              <th>Name</th>
            </tr>
        <?php 
echo $personId;
?>
">
      </div>
    </div>
    <button type="submit" class="btn btn-primary">Read Person</button>
  </form>
  <br>

<?php 
if ($personId) {
    // First we make a request to the API for the person and save the response
    $response = $client->familytree()->readPersonById($personId);
    // Check for errors
    if ($response->hasError()) {
        handleErrors($response);
    } else {
        // Then we get the person from the response
        $person = $response->getPerson();
        // Then we trasnition to the memories (artifacts) from the person response
        $memoriesResponse = $response->readArtifacts();
        // Then we pull the GEDCOM X document from the response
        $gedx = $memoriesResponse->getEntity();
        // Memories are listed as source descriptions in the gedcomx document
        // See https://familysearch.org/developers/docs/api/tree/Read_Person_Memories_usecase
        foreach ($gedx->getSourceDescriptions() as $memory) {
            ?>
        <div class="panel panel-default">
          <div class="panel-heading"><code><?php 
            echo $memory->getMediaType();
            ?>
Beispiel #3
0
    $res = postCreate($_POST["topic"], $user["id"], $_POST["message"]);
    handleErrors($res);
    header("location: index.php?topic_id=" . $_POST["topic"]);
}
if (isset($_GET["newtopic"])) {
    $user = userGetLoggedIn();
    if (isset($_POST["parent"])) {
        $parent = $_POST["parent"];
    } else {
        $parent = -1;
    }
    $res = topicCreate($_POST["title"], $user["id"], $parent);
    handleErrors($res);
    $topic = topicGetByTitle($_POST["title"]);
    $res = postCreate($topic["id"], $user["id"], $_POST["message"]);
    handleErrors($res);
    header("location: index.php?topic_id=" . $topic["id"]);
}
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
	<meta http-equiv="Content-Type" content="text/html; charset=WINDOWS-1251" />

	<style type="text/css">
		@import "stylesheet.css";
	</style>

	<script src="jquery-1.3.2.js"></script>
 if (isset($params['spouseSurname'])) {
     $query->spouseSurname($params['spouseSurname']);
 }
 // You can avoid all of the previous code duplication using dynamic method calls.
 // http://stackoverflow.com/questions/251485/dynamic-class-method-invocation-in-php
 //
 // foreach($validParams as $searchParam){
 //  if($params[$searchParam]){
 //    $query->$searchParam($params[$searchParam]);
 //  }
 // }
 // First we make a request to the API for the person and save the response
 $searchResponse = $client->familytree()->searchForPersons($query);
 // Check for errors
 if ($searchResponse->hasError()) {
     handleErrors($searchResponse);
 } else {
     ?>
     <h3>Results</h3>
     <table class="table">
       <tr>
         <th>Id</th>
         <th>Name</th>
         <th>Birth</th>
         <th>Death</th>
       </tr>
   <?php 
     $entries = $searchResponse->getResults()->getEntries();
     foreach ($entries as $entry) {
         // The ID of the entry matches the ID of the primary person in the result.
         // Results may also contain spouses and parents so we need the ID to
         if ($relationship->getPerson1()->getResourceId() === $person->getId()) {
             $spouse1 = $person;
             $spouse2 = $spousesResponse->getPerson($relationship->getPerson2());
         } else {
             $spouse1 = $spousesResponse->getPerson($relationship->getPerson1());
             $spouse2 = $person;
         }
         printRelationship($relationship, $spouse1, $spouse2);
     }
 }
 echo '<h3>Child Relationships</h3>';
 // Request the parents and relationships to parents from the API
 $childrenResponse = $personResponse->readChildren();
 // Check for errors
 if ($childrenResponse->hasError()) {
     handleErrors($childrenResponse);
 } else {
     // Print each child and parents relationships in the response
     foreach ($childrenResponse->getChildAndParentsRelationships() as $relationship) {
         // The children response _only_ contains children; it does not contain
         // the parents. We know that one of the parents is the primary person
         // which we have a reference to from above. We need to figure out whether
         // they are the mother or father.
         //
         // The other parent is likely a spouse in which case we have a
         // reference to them in the spouses response. But the other parent
         // doesn't have to be a spouse. A child and parents relationship can
         // exist without the two parents having a spouse relationship.
         // In those cases you'll need to make an additional request for the
         // other parent. We don't do that here.
         $child = $childrenResponse->getPerson($relationship->getChild());