Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Test Twitter API */
- use Abraham\TwitterOAuth\TwitterOAuth;
- function test_twitter_api() {
- $counter = 0;
- if ( class_exists( 'Abraham\TwitterOAuth\TwitterOAuth' ) ) {
- $tw_consumer_key = 'your_key'; /* Twitter Consumer Key */
- $tw_consumer_secret = 'your_key'; /* Twitter Consumer Secret */
- $tw_access_token = 'your_key'; /* Twitter Access Token */
- $tw_access_token_secret = 'your_key'; /* Twitter Access Token Secret */
- $twitter_id = 'TwitterDev'; /* @TwitterDev || https://twitter.com/TwitterDev */
- $twitter = new TwitterOAuth( $tw_consumer_key, $tw_consumer_secret, $tw_access_token, $tw_access_token_secret );
- $userinfo = $twitter->get( 'users/lookup', array( 'screen_name' => $twitter_id ) );
- if ( empty( $userinfo ) || $userinfo->errors ) { /* If Error */
- var_dump('Failed to Get data'); echo '<br>';
- var_dump($userinfo); echo '<br>';
- var_dump($userinfo->errors[0]->message); echo '<br>';
- }else { /* If Success */
- var_dump('Successfully Getting data'); echo '<br>';
- var_dump($userinfo); echo '<br>';
- $counter = (int) $userinfo[0]->followers_count;
- }
- }
- var_dump($counter);
- }
- add_action( 'jnews_after_body', 'test_twitter_api' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement