Skip to content
This repository has been archived by the owner on Jun 21, 2023. It is now read-only.

Commit

Permalink
support for setting custom persistent data handler
Browse files Browse the repository at this point in the history
  • Loading branch information
adrian7 committed Oct 2, 2017
1 parent 5f194c2 commit 028a02b
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 8 deletions.
26 changes: 21 additions & 5 deletions src/API/Facebook/App.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

namespace DevLib\API\Facebook;

use Facebook\Facebook;
use Facebook\Authentication\OAuth2Client;
use Facebook\Exceptions\FacebookSDKException;
use Facebook\Exceptions\FacebookResponseException;
Expand Down Expand Up @@ -50,30 +51,37 @@ class App{
protected $provider;

/**
* FB Login Constructor.
* FB App Constructor.
*
* @param $appId
* @param $appSecret
* @param $callbackURL
* @param array $permissions
* @param null $persistentDataHandler
* @param string $defaultGraphVersion
*/
public function __construct(
$appId,
$appSecret,
$callbackURL,
$permissions=['id', 'email'],
$defaultGraphVersion='v2.10'
$persistentDataHandler=NULL,
$defaultGraphVersion='latest'
) {

$this->appId = $appId;
$this->callbackUrl = $callbackURL;

$defaultGraphVersion = ( 'latest' == $defaultGraphVersion ) ?
Facebook::DEFAULT_GRAPH_VERSION :
$defaultGraphVersion;

//init provider
$this->provider = GraphAccessProvider::getInstance([
'app_id' => $appId,
'app_secret' => $appSecret,
'default_graph_version' => $defaultGraphVersion
'app_id' => $appId,
'app_secret' => $appSecret,
'persistent_data_handler' => $persistentDataHandler,
'default_graph_version' => $defaultGraphVersion
]);

//init redirect helper
Expand All @@ -84,6 +92,14 @@ public function __construct(

}

public static function create(){
//TODO Allow creation using static
}

public static function withGraphAccessProvider(GraphAccessProvider $provider){
//TODO
}

/**
* @param $message
* @param string $type
Expand Down
9 changes: 6 additions & 3 deletions src/API/Facebook/GraphAccessProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,18 @@ protected function __construct(Facebook $facebook) {
/**
* Retrieve a graph access provider instance
* @param array $params
* @param null|string $instanceId
*
* @return GraphAccessProvider
* @return mixed
*/
public static function getInstance(array $params){
public static function getInstance(array $params, $instanceId=NULL){

if( ! isset($params['app_id']) or ! isset($params['app_secret']) )
throw new \InvalidArgumentException("Missing app_id or app_secret from input params... .");

$instanceId = substr(strval($params['app_id']), 0, 7);
$instanceId = empty($instanceId) ?
substr( strval($params['app_id']), 0, 7 ) :
$instanceId;

if( ! isset( self::$instances[$instanceId] ) ){

Expand Down

0 comments on commit 028a02b

Please sign in to comment.