Skip to content

Instantly share code, notes, and snippets.

@ptim
Last active December 17, 2015 06:59
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 ptim/5569544 to your computer and use it in GitHub Desktop.
Save ptim/5569544 to your computer and use it in GitHub Desktop.
!!! WARNING!! THIS EXPOSES YOUR PRIVATE TWITTER API KEYS AND SECRETS !!! You'll need to regenerate the keys as soon as you make them public: https://dev.twitter.com/apps/
<?php
/*
Debug shortcode for Twitget.
!!! WARNING!! THIS EXPOSES YOUR PRIVATE TWITTER API KEYS AND SECRETS !!!
You'll need to regenerate the keys as soon as you make them public:
https://dev.twitter.com/apps/
To use:
- paste this code into the very bottom of the file twitget.php ( after ?> )
- create a private post
- enter the shortcode [twitget-debug]
*/
if(!class_exists('tmhOAuth')) {
return "Twitget is not active";
}
add_shortcode('twitget-debug', 'twitget_debug_shortcode_handler');
// Debug function
function twitget_debug_shortcode_handler($attributes, $content = null) {
$options = get_option('twitget_settings');
$tmhOAuth = new tmhOAuth(
array(
'consumer_key' => $options['consumer_key'],
'consumer_secret' => $options['consumer_secret'],
'user_token' => $options['user_token'],
'user_secret' => $options['user_secret'],
'curl_ssl_verifypeer' => false
)
);
ob_start();
$code = $tmhOAuth->request('GET', $tmhOAuth->url('1/account/verify_credentials'));
if ($code == 200) {
echo 'The access level of this token is: ' . $tmhOAuth->response['headers']['x_access_level'] . PHP_EOL;
tmhUtilities::pr($tmhOAuth->response);
} else {
tmhUtilities::pr(htmlentities($tmhOAuth->response['response']));
}
echo "\n\n========================================\n\n";
var_dump($tmhOAuth);
$dataDump = ob_get_clean();
return '<pre>'. $dataDump . '</pre>';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment