Skip to content

Instantly share code, notes, and snippets.

@drrobotnik
Created September 15, 2014 17:41
Show Gist options
  • Save drrobotnik/260e50dd6cf49d6725a7 to your computer and use it in GitHub Desktop.
Save drrobotnik/260e50dd6cf49d6725a7 to your computer and use it in GitHub Desktop.
function cv_twitter_get( $method='', $args=array() ){
$implode_args = implode('_', $args);
$sani_method = sanitize_title_with_dashes( $method );
$sani_args = sanitize_title_with_dashes( $implode_args );
$transient = $sani_method . '_' . $sani_args;
// avoid rate limiting
if ( false === ( $result = get_transient( $transient ) ) ) {
require_once( get_stylesheet_directory() . '/inc/twitteroauth/twitteroauth.php');
$connection = new TwitterOAuth('', '', '', '');
$result = $connection->get( $method, $args );
if( empty( $result->errors ) )
set_transient( $transient, $result, 60*10 ); // 10 minutes
}
return $result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment