Created
June 23, 2015 20:03
-
-
Save nitriques/f59db0af0c1b88c2a9ba to your computer and use it in GitHub Desktop.
Twitter Remote Data Source for Symphony CMS
This file contains 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(EXTENSIONS . '/remote_datasource/data-sources/datasource.remote.php'); | |
Class datasourcetwitter extends RemoteDatasource { | |
public $dsParamROOTELEMENT = 'twitter'; | |
public $dsParamURL = 'https://api.twitter.com/1.1/statuses/user_timeline.json?include_entities=true&include_rts=true&screen_name=ACCOUNT_NAME&count=10'; | |
public $dsParamFORMAT = 'json'; | |
public $dsParamXPATH = '/'; | |
public $dsParamCACHE = 30; | |
public $dsParamTIMEOUT = 10; | |
public static function prepareGateway(&$ch) { | |
// to generate bearer token, create and app at https://apps.twitter.com/ | |
// aand then go to http://twitter-bearer-token.herokuapp.com/ | |
$ch->setopt('HTTPHEADER',array('Content-Type: application/x-www-form-urlencoded;charset=UTF-8')); | |
$ch->setopt('HTTPHEADER',array('Authorization: Bearer AAAAAAAAAAAAAAAAAAAAAIu%2FfgAAAAAAK7adp...')); | |
} | |
public function __construct($env=NULL, $process_params=true){ | |
parent::__construct($env, $process_params); | |
$this->_dependencies = array(); | |
} | |
public function about(){ | |
return array( | |
'name' => 'Twitter', | |
'author' => array( | |
'name' => 'Your name', | |
'website' => 'http://example.com', | |
'email' => '[email protected]'), | |
'version' => 'Symphony 2.6.1', | |
'release-date' => '2015-05-13T14:30:04+00:00' | |
); | |
} | |
public function allowEditorToParse(){ | |
return true; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment