Created
May 19, 2012 10:02
-
-
Save davidpmccormick/2730312 to your computer and use it in GitHub Desktop.
Custom DS for Symphony CMS – add Facebook access token to param pool
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_once(TOOLKIT . '/class.datasource.php'); | |
Class datasourceaccess_token extends Datasource{ | |
function about(){ | |
return array('name' => 'access token'); | |
} | |
function __construct(&$parent, $env=NULL, $process_params=true){ | |
parent::__construct($parent, $env, $process_params); | |
$this->_dependencies = array(); | |
} | |
public function allowEditorToParse(){ | |
return false; | |
} | |
public function grab(&$param_pool){ | |
$theAccessToken = file_get_contents('https://graph.facebook.com/oauth/access_token?grant_type=client_credentials&client_id=xxxxxxxxxxxxx&client_secret=xxxxxxxxxxxxx'); | |
if($theAccessToken){ | |
$param_pool['accesstoken'] = $theAccessToken; | |
}else{ // it seemed sensible to fallback to something if file_get_contents() didn't work; | |
$param_pool['accesstoken'] = 'access_token=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment