Skip to content

Instantly share code, notes, and snippets.

@cogdog
Created May 23, 2016 20:20
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 cogdog/2934cddc5e1f4f446ff84a44618fff82 to your computer and use it in GitHub Desktop.
Save cogdog/2934cddc5e1f4f446ff84a44618fff82 to your computer and use it in GitHub Desktop.
Dailyblank Fetch Some Tweets
<?php
// I used this when testing the twitter fetching,
// it will give you sense of what tweets will be fetched
// for a Daily blank site. Insert into the magic spot of page-debug.php, go to /debug on your
// site, let it do its work, then remove.
$tweets = getTweets( dailyblank_option('twitteraccount'), 200, array('exclude_replies'=>false, 'trim_user' => false ) );
// walk through the tweets
foreach($tweets as $tweet) {
// array for hashtags
$hashtags = extract_hashtags( $tweet['entities']['hashtags'] );
// We want only replies with hashtags and URLs in 'em
if ( $hashtags ) {
// check for hashtag match against our dailyblank base
if ( dailyblank_tag_in_hashtags( $hashtags, dailyblank_option('basetag') ) ) {
// bingo we got a winner;
// form URL for the tweet
$t_url = 'https://twitter.com/' . $tweet['user']['screen_name'] . '/status/' . $tweet['id_str'];
echo wp_oembed_get( $t_url );
}
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment