Created
September 15, 2014 17:41
-
-
Save drrobotnik/260e50dd6cf49d6725a7 to your computer and use it in GitHub Desktop.
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
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