-
Notifications
You must be signed in to change notification settings - Fork 15
Using the SDK Documentation
To orient you on how to navigate the PHP SDK documentation, it would be helpful to follow the documentation through the steps of getting the name of a person in the Family Tree.
Activity: Open the PHP SDK documentation and enter FamilySearchClient in the Search box to find and display the FamilySearchClient class. From there follow the states listed in the following steps and locate the methods in the documentation. As you go, notice some of the other methods that are available in the various states. You can also examine tutorial.php or the sample app code to see how to code the methods.
-
You must first populate a FamilySearchClient class array with an app key, a redirect URI, and an access token. The FamilySearchClient class contains the _construct method along with other methods. Examine the structure of the _construct array in the documentation?
-
With the array populated you must use the PHP "new" command to create a FamilySearchClient class instance (see the tutorial.php file to see how this is done). This places you in the FamilySearchClient state. You must transition from one "class" state to another by executing methods that are in the current state.
-
Use the getOAuth2AuthorizationURI() method to ask the user to login.
-
Use the authenticateViaOAuth2AuthCode($code) method and the getAccessToken() getter to retrieve the authorized access token.
After authenticating with FamilySearch, the following steps will transition you from state to state in order to obtain information about a person you have identified by person ID. These steps show how to get the person's name.
-
Use the familytree() method to transition to the FamilyTreeCollectionState.
-
Use the readPersonById() method to transition to the FamilyTreePersonState.
-
The FamilyTreePersonState inherits the getPerson() method from the PersonState. Use the getPerson() method to transition to the Person state.
-
Use the getDisplayExtension() method to retrieve the DisplayProperties.
-
Get the person's name from the DisplayProperties by using the getName() getter.
You might want to examine the sample app as your next step, or simply get started coding on your own.