PHPackages                             benhall14/php-twitter-widget - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. benhall14/php-twitter-widget

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

benhall14/php-twitter-widget
============================

A PHP alternative to the Twitter Embed Timelines JavaScript.

1.0(9y ago)4421MITPHPPHP &gt;=5.5

Since Apr 14Pushed 6y ago1 watchersCompare

[ Source](https://github.com/benhall14/php-twitter-widget)[ Packagist](https://packagist.org/packages/benhall14/php-twitter-widget)[ Docs](https://github.com/benhall14/php-twitter-widget)[ RSS](/packages/benhall14-php-twitter-widget/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (1)DependenciesVersions (2)Used By (0)

PHP Twitter Widget
==================

[](#php-twitter-widget)

A PHP alternative to the Twitter Embed Timelines JavaScript.

Twitter Embedded Timelines allow you to show your latest tweets using JavaScript. While this can help you easily implement your latest tweets on you website, I needed to create a similar effect without including any additional JavaScript files on the web page.

I decided to create a script that will fetch tweets server side, and allow for including in a web page without JavaScript includes. I also needed to ensure I cached the result, to avoid hitting API limits.

Using the popular TwitterOAuth PHP Library for authentication, we can access the Twitter Rest API.

Works with *PHP 5.3+ through to **PHP 7**.*

Usage
=====

[](#usage)

First, you need to head over to [](https://apps.twitter.com/) and register your new Application. You will need the following keys for your new 'App'.

- Consumer Key
- Consumer Secret Key (This must always remain private)
- Access Token
- Access Token Secret

You can now install the PHP Twitter Widget using composer:

```
composer install benhall14/php-twitter-widget
```

To implement, first instantiate a TwitterWidget with your credentials to fetch the feed. The feed will be cached so we don't call the API on every page load. The default cache file age limit is 3600 seconds (1 hour).

```
require '../vendor/autoload.php';

try {
    $twitterWidget = new TwitterWidget(
        $consumer_key,             # your Twitter consumer key
        $consumer_secret,          # your Twitter consumer secret
        $access_token,             # your Twitter access token
        $access_token_secret,      # your Twitter access token secret
        'nasa',                    # the screen name of the Twitter feed to display
        15,                        # the number of tweets to return
        '../cache/twitter_status_feed.json', # path to the cache file
        3600                       # the number of seconds to cache the feed for, default is 3600 (1 hour)
    );
} catch (Exception $e) {
    /* handle any error thrown, such as unwritable cache file */
    echo $e->getMessage();
}
```

You can then use the following to display the feed on your web page, passing the your chosen feed title, such as "My Tweets". The second optional parameter should be a boolean of whether to print(true) or return(false) the formatted feed. The third optional parameter is the tweet date format - default = M d H:i A.

```
echo $twitterWidget->display('My Tweets', true, 'M d H:i A');
```

Requirements
============

[](#requirements)

**Works with PHP 5.3, PHP 5.5, PHP 5.6, and PHP 7**

**PHP CURL Extension**

**TwitterOAuth Library**

License
=======

[](#license)

Copyright (c) 2016-2017 Benjamin Hall,

Licensed under the MIT license

Donate?
=======

[](#donate)

If you find this project helpful or useful in anyway, please consider getting me a cup of coffee - It's really appreciated :)

[![Donate](https://camo.githubusercontent.com/604e3db9c8751116b3f765aad0353ec7ded655bbe8aaacbc38d8c4a6b784b3ed/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f446f6e6174652d50617950616c2d677265656e2e737667)](https://paypal.me/benhall14)

###  Health Score

28

—

LowBetter than 52% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

3365d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/17323507?v=4)[Benjamin Hall](/maintainers/benhall14)[@benhall14](https://github.com/benhall14)

---

Top Contributors

[![benhall14](https://avatars.githubusercontent.com/u/17323507?v=4)](https://github.com/benhall14 "benhall14 (7 commits)")

---

Tags

phptweettwittertwitter-apitwitter-feedtwitter

### Embed Badge

![Health badge](/badges/benhall14-php-twitter-widget/health.svg)

```
[![Health](https://phpackages.com/badges/benhall14-php-twitter-widget/health.svg)](https://phpackages.com/packages/benhall14-php-twitter-widget)
```

###  Alternatives

[mpratt/embera

Oembed consumer library. Converts urls into their html embed code. Supports 150+ sites, such as Youtube, Twitter, vimeo, Instagram etc.

3636.0M27](/packages/mpratt-embera)[cwspear/bootstrap-hover-dropdown

An unofficial Bootstrap plugin to enable Bootstrap dropdowns to activate on hover and provide a nice user experience.

1.2k156.0k](/packages/cwspear-bootstrap-hover-dropdown)[arcanedev/seo-helper

SEO Helper is a framework agnostic package that provides tools &amp; helpers for SEO (Laravel supported).

337471.4k4](/packages/arcanedev-seo-helper)[nystudio107/craft-seomatic

SEOmatic facilitates modern SEO best practices &amp; implementation for Craft CMS 5. It is a turnkey SEO system that is comprehensive, powerful, and flexible.

1741.5M53](/packages/nystudio107-craft-seomatic)[nojimage/twitter-text-php

A library of PHP classes that provide auto-linking and extraction of usernames, lists, hashtags and URLs from tweets.

1192.0M7](/packages/nojimage-twitter-text-php)[honeystone/laravel-seo

SEO metadata and JSON-LD package for Laravel.

35590.0k](/packages/honeystone-laravel-seo)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
