Last active
August 29, 2015 14:17
-
-
Save jimmyz/2c461ec3a2bfde8446a5 to your computer and use it in GitHub Desktop.
FamilySearch PHP SDK Proposal
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'; | |
use FamilySearch\Client; | |
$client = new FamilySearch\Client(array( | |
'redirectURI'=>'http://localhost:5000/familysearch-auth.php', | |
'clientId'=>'a0T3000000BfM3mEAF', | |
'collection_uri' => 'https://sandbox.familysearch.org/platform/collections' //default to the sandbox | |
)); | |
if($_GET['code']){ | |
$accessToken = $client->getOAuth2AccessTokenFromCode($code); | |
session_start(); | |
$_SESSION['fs_access_token'] = $accessToken; | |
header('Location: /index.php'); | |
}else{ | |
header('Location: '.$client->getOAuth2AuthorizationURI()); | |
} | |
?> |
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'; | |
use FamilySearch\Client; | |
if(isset($_SESSION['fs_access_token'])){ | |
$client = new FamilySearch\Client(array( | |
'redirectURI'=>'http://localhost:5000/familysearch-auth.php', //These settings would be optional at this point | |
'clientId'=>'a0T3000000BfM3mEAF', // | |
'accessToken'=> $_SESSION['fs_access_token'] | |
)); | |
$personState = $client->familytree()->readCurrentUserPerson(); | |
$person = $personState->getPerson(); | |
echo $person->getFullName(); | |
$personState = $client->familytree()->readPerson('KWQS-BBQ'); | |
$person = $personState->getPerson(); | |
echo $person->getFullName(); | |
}else{ | |
header('Location: familysearch-auth.php'); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
+1