Skip to content

Instantly share code, notes, and snippets.

@michael-e
Forked from nitriques/data.twitter.php
Last active August 29, 2015 14:23
Show Gist options
  • Save michael-e/01452cee2e7ed270fcaf to your computer and use it in GitHub Desktop.
Save michael-e/01452cee2e7ed270fcaf to your computer and use it in GitHub Desktop.
<?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@example.com'),
'version' => 'Symphony 2.6.1',
'release-date' => '2015-05-13T14:30:04+00:00'
);
}
public function allowEditorToParse(){
return true;
}
}
@michael-e
Copy link
Author

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