Skip to content

Instantly share code, notes, and snippets.

@davidpmccormick
Created May 19, 2012 10:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davidpmccormick/2730312 to your computer and use it in GitHub Desktop.
Save davidpmccormick/2730312 to your computer and use it in GitHub Desktop.
Custom DS for Symphony CMS – add Facebook access token to param pool
<?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