Skip to Content
Menu

twitter_cache()

Generate a Twitter feed for a user or a list (can be called by AJAX).

PHP February 14, 2018

Usage

PHP
nebula()->twitter_cache($username, $listname, $number_tweets, $include_retweets)

Parameters

$username
(Required) (String) The username to pull the feed of
Default: Great_Blakes

$listname
(Optional) (String) If using a list, the name of the list
Default: None

$numbertweets
(Optional) (Integer) The number of Tweets to get
Default: 5

$includeretweets
(Optional) (Boolean) Whether to include retweets
Default: true

Parameter Notes

This function requires a Twitter Bearer Token to be generated and set in Nebula Options!

If calling this function by AJAX, the data object should use the parameter names without the “$”.

Request or provide clarification »

Examples

Get the full tweet with clickable usernames, hashtags, and URLs.

PHP
<?php
    $tweets = nebula()->twitter_cache('Great_Blakes');
    echo $tweet->markup;    //This key is added by Nebula
?>

Demo


Example 1 (PHP)
Retrieve tweets with only PHP

Fatal error: Uncaught Error: Attempt to assign property "tweet_url" on array
in /home/gearside/public_html/nebula.gearside.com/wp-content/themes/Nebula-main/libs/Functions.php on line 2368

Call stack:

  1. Nebula::{closure}()
    wp-content/themes/Nebula-main/libs/Utilities/Utilities.php:730
  2. Nebula::transient()
    wp-content/themes/Nebula-main/libs/Functions.php:2344
  3. Nebula::twitter_cache()
    wp-content/plugins/nebula-docs/demos/twitter_cache.php:102
  4. include_once()
    wp-content/plugins/nebula-docs/templates/function-doc.php:192
  5. include()
    wp-includes/template-loader.php:106
  6. require_once()
    wp-blog-header.php:19
  7. require()
    index.php:17

Query Monitor