Skip to content

Instantly share code, notes, and snippets.

@jimmyz
Last active August 29, 2015 14:17
Show Gist options
  • Save jimmyz/2c461ec3a2bfde8446a5 to your computer and use it in GitHub Desktop.
Save jimmyz/2c461ec3a2bfde8446a5 to your computer and use it in GitHub Desktop.
FamilySearch PHP SDK Proposal
<?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());
}
?>
<?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');
}
?>
@stoicflame
Copy link

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment