PHPackages                             rezozero/mixedfeed - 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. [API Development](/categories/api)
4. /
5. rezozero/mixedfeed

ActiveLibrary[API Development](/categories/api)

rezozero/mixedfeed
==================

A PHP library to get social networks feeds and merge them

v4.0.1(2y ago)11130.4k↓47%18[1 issues](https://github.com/rezozero/mixedfeed/issues)MITPHPPHP &gt;=7.4

Since Jun 19Pushed 2y ago15 watchersCompare

[ Source](https://github.com/rezozero/mixedfeed)[ Packagist](https://packagist.org/packages/rezozero/mixedfeed)[ RSS](/packages/rezozero-mixedfeed/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (3)Dependencies (11)Versions (41)Used By (0)

mixedfeed
=========

[](#mixedfeed)

> A PHP library to rule social-feeds, to entangle them with magic, a PHP library to gather them and bind them in darkness

[![SensioLabsInsight](https://camo.githubusercontent.com/0bb109bfb1963476d05527bfe213581aa29f899b736ae8c806b46da180746c08/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f65643335343464652d376436342d346566392d613535312d6336316136366662363638642f6d696e692e706e67)](https://insight.sensiolabs.com/projects/ed3544de-7d64-4ef9-a551-c61a66fb668d)[![License](https://camo.githubusercontent.com/983b830a7ca1046c98084fb90a40c6f9c599851ade288e16d9476a7f3e95bab6/687474703a2f2f696d672e736869656c64732e696f2f3a6c6963656e73652d6d69742d626c75652e7376673f7374796c653d666c6174)](https://camo.githubusercontent.com/983b830a7ca1046c98084fb90a40c6f9c599851ade288e16d9476a7f3e95bab6/687474703a2f2f696d672e736869656c64732e696f2f3a6c6963656e73652d6d69742d626c75652e7376673f7374796c653d666c6174) [![Packagist](https://camo.githubusercontent.com/6d902d79f6ccf5c7d92f60a3289ea7dfa47ddd22366c04d7b5af9c13894c912a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f72657a6f7a65726f2f6d69786564666565642e7376673f7374796c653d666c6174)](https://packagist.org/packages/rezozero/mixedfeed)[![Build Status](https://camo.githubusercontent.com/66ab1b14ace3fee7688cf23331709d4c959e54eed12d3a26caefd62a9ac6409b/68747470733a2f2f7472617669732d63692e6f72672f72657a6f7a65726f2f6d69786564666565642e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/rezozero/mixedfeed)

- [Use standalone Docker server](#use-standalone-docker-server)
    - [Available environment variables](#available-environment-variables)
- [Install as library](#install-as-library)
- [Combine feeds](#combine-feeds)
- [Use *FeedItem* instead of raw feed](#use-feeditem-instead-of-raw-feed)
- [Feed providers](#feed-providers)
- [Modify cache TTL](#modify-cache-ttl)
- [Create your own feed provider](#create-your-own-feed-provider)
    - [Create a feed provider from a *Doctrine* repository](#create-a-feed-provider-from-a-doctrine-repository)

Use standalone Docker server
----------------------------

[](#use-standalone-docker-server)

```
docker pull rezozero/mixedfeed

docker run -p 8080:80 \
    -e MF_FACEBOOK_PAGE_ID="xxx" \
    -e MF_FACEBOOK_ACCESS_TOKEN="xxxx" \
    -e MF_INSTAGRAM_USER_ID="xxx" \
    -e MF_INSTAGRAM_ACCESS_TOKEN="xxxx" \
    -e MF_CACHE_PROVIDER="apcu" \
    -e MF_FEED_LENGTH="30" \
    rezozero/mixedfeed

```

or use `docker-compose`: copy `docker-compose.yml` to `docker-compose.test.yml` and fill your provider credentials in it. Then execute `docker-compose -f docker-compose.test.yml up -d --force-recreate`, *Mixedfeed* will be available at

### Available environment variables

[](#available-environment-variables)

NameDefault valueMultiple? (comma separated)MF\_CACHE\_PROVIDERarrayMF\_FEED\_LENGTH12MF\_FACEBOOK\_PAGE\_ID✅MF\_FACEBOOK\_ACCESS\_TOKENMF\_FACEBOOK\_FIELDSfrom,link,picture,full\_picture,message,story,type,created\_time,source,status\_type✅MF\_FACEBOOK\_ENDPOINTMF\_GRAPH\_INSTAGRAM\_USER\_ID✅MF\_GRAPH\_INSTAGRAM\_ACCESS\_TOKEN✅MF\_GITHUB\_RELEASES\_REPOSITORY✅MF\_GITHUB\_COMMITS\_REPOSITORY✅MF\_GITHUB\_ACCESS\_TOKENMF\_MEDIUM\_USERNAME✅MF\_MEDIUM\_USER\_ID*Use same order as in `MF_MEDIUM_USERNAME`*✅MF\_PINTEREST\_BOARD\_ID✅MF\_PINTEREST\_ACCESS\_TOKENMF\_INSTAGRAM\_OEMBED\_ID✅MF\_TWITTER\_SEARCH\_QUERYMF\_TWITTER\_USER\_ID✅MF\_TWITTER\_ACCESS\_TOKENMF\_TWITTER\_ACCESS\_TOKEN\_SECRETMF\_TWITTER\_CONSUMER\_KEYMF\_TWITTER\_CONSUMER\_SECRETMF\_TWITTER\_EXTENDED\_MODE0MF\_YOUTUBE\_PLAYLIST\_ID✅MF\_YOUTUBE\_API\_KEYInstall as library
------------------

[](#install-as-library)

*mixedfeed* v3+ needs at least PHP **7.2**, check your server configuration.

```
composer require rezozero/mixedfeed
```

```
use RZ\MixedFeed\MixedFeed;
use RZ\MixedFeed\GraphInstagramFeed;
use RZ\MixedFeed\TwitterFeed;
use RZ\MixedFeed\TwitterSearchFeed;
use RZ\MixedFeed\FacebookPageFeed;
use RZ\MixedFeed\GithubReleasesFeed;
use RZ\MixedFeed\GithubCommitsFeed;

$feed = new MixedFeed([
    new GraphInstagramFeed(
        'instagram_user_id',
        'instagram_access_token',
        null ,// you can add a doctrine cache provider
        [] // And a fields array to retrieve too
    ),
    new TwitterFeed(
        'twitter_user_id',
        'twitter_consumer_key',
        'twitter_consumer_secret',
        'twitter_access_token',
        'twitter_access_token_secret',
        null,  // you can add a doctrine cache provider
        true,  // exclude replies true/false
        false, // include retweets true/false
        false  // extended mode true/false
    ),
    new TwitterSearchFeed(
        [
            '#art', // do not specify a key for string searchs
            'from' => 'rezo_zero',
            'since' => '2015-11-01',
            'until' => '2015-11-30',
        ],
        'twitter_consumer_key',
        'twitter_consumer_secret',
        'twitter_access_token',
        'twitter_access_token_secret',
        null,  // you can add a doctrine cache provider
        false  // extended mode true/false
    ),
    new FacebookPageFeed(
        'page-id',
        'app_access_token',
        null, // you can add a doctrine cache provider
        [],    // And a fields array to retrieve too
        null // A specific Graph API Endpoint URL
    ),
    new GithubCommitsFeed(
        'symfony/symfony',
        'access_token',
        null // you can add a doctrine cache provider
    ),
    new GithubReleasesFeed(
        'roadiz/roadiz',
        'access_token',
        null // you can add a doctrine cache provider
    ),
    new \RZ\MixedFeed\YoutubePlaylistItemFeed(
        'your_playlist_id',
        'api_key',
        null // you can add a doctrine cache provider
    ),
]);

return $feed->getItems(12);
// Or use canonical \RZ\MixedFeed\Canonical\FeedItem objects
// for a better compatibility and easier templating with multiple
// social platforms.
return $feed->getAsyncCanonicalItems(12);
```

Combine feeds
-------------

[](#combine-feeds)

*mixedfeed* can combine multiple social feeds so you can loop over them and use some common data fields such as `feedItemPlatform`, `normalizedDate` and `canonicalMessage`. *mixedfeed* will sort all your feed items by *descending* `normalizedDate`, but you can configure it to sort *ascending*:

```
new MixedFeed([…], MixedFeed::ASC);
```

Each feed provider must inject these three parameters in feed items:

- `feedItemPlatform`: This is your social network name as a *string* i.e. «twitter». It will be important to cache your feed and for your HTML template engine to render properly each feed item.

For example, if you are using *Twig*, you will be able to include a sub-template for each social-platform.

```
{% for socialItem in mixedFeedItems %}
{% include ‘social-blocks/‘ ~ socialItem.feedItemPlatform ~ ‘.html.twig’ %}
{% endfor %}
```

- `normalizedDate`: This is a critical parameter as it allows *mixedfeed* to sort *reverse chronologically* multiple feeds with heterogeneous structures.
- `canonicalMessage`: This is a useful field which contains the **text content** for each item over **all** platforms. You can use this to display items texts within a simple loop.

Use *FeedItem* instead of raw feed
----------------------------------

[](#use-feeditem-instead-of-raw-feed)

If you need to serialize your MixedFeed to JSON or XML again, you should not want all the raw data contained in each social feed item. So you can use the `$feed->getAsyncCanonicalItems(12);` method instead of `getItems` to get a more concise object with essential data: `RZ\MixedFeed\Canonical\FeedItem`. *FeedItem* will provide these fields:

- id `string`
- platform `string`
- author `string`
- link `string`
- title `string`
- message `string`
- likeCount `int|null`
- shareCount `int|null`: Share, comments or retweet count depending on platform.
- images `Image[]`
    - url `string`
    - width `integer`
    - height `integer`
- dateTime `DateTime`
- tags `array` (only used with `MediumFeed`)
- raw `stdClass` to access raw API object if canonical item fields are not enough

When FeedItem has images, `FeedItem::$images` will hold an array of `RZ\MixedFeed\Canonical\Image` objects to have better access to its `url`, `width` and `height` if they're available.

Each feed provider must implement how to *hydrate* a `FeedItem` from the raw feed overriding `createFeedItemFromObject()`method.

Feed providers
--------------

[](#feed-providers)

Feed provider classDescription`feedItemPlatform`MediumFeedCall over `https://medium.com/username/latest` endpoint. It only needs a `$username` and an optional `$userId` for better consistency over requests (Medium seems to apply cache on their username requests even after changing a query parameter, i.e. post limit). *Medium* allows maximum 14 posts per requests.`medium`InstagramOEmbedFeedCall over `https://api.instagram.com/oembed/` endpoint. It only needs a `$embedUrls` array`instagram_oembed`GraphInstagramFeedCall over `graph.instagram.com/$userId/media` endpoint with [Basic Display API](https://developers.facebook.com/docs/instagram-basic-display-api). It needs a `$userId` and an `$accessToken`. **Warning**: Access token must be refreshed every 60 days, use `RefreshInstagramAccessToken``instagram`InstagramFeed*Deprecated*: Call over `/v1/users/$userId/media/recent/` endpoint. It needs a `$userId` and an `$accessToken``instagram`TwitterFeedCall over `statuses/user_timeline` endpoint. It requires a `$userId`, a `$consumerKey`, a `$consumerSecret`, an `$accessToken` and an `$accessTokenSecret`. Be careful, this [endpoint](https://dev.twitter.com/rest/reference/get/statuses/user_timeline) can **only return up to 3,200 of a user’s most recent Tweets**, your item count could be lesser than expected. In the same way, Twitter removes retweets after retrieving the items count.`twitter`TwitterSearchFeedCall over `search/tweets` endpoint. It requires a `$queryParams` array, a `$consumerKey`, a `$consumerSecret`, an `$accessToken` and an `$accessTokenSecret`. Be careful, Twitter API **won’t retrieve tweets older than 7 days**, your item count could be lesser than expected. `$queryParams` must be a *key-valued* array with *query operators* according to [Twitter API documentation](https://dev.twitter.com/rest/public/search).`twitter`FacebookPageFeedCall over `https://graph.facebook.com/v3.3/$pageId/posts` endpoint by default. Endpoint can be changed using `$apiBaseUrl` parameter. It requires a `$pageId` and an `$accessToken`. This feed provider only works for public Facebook **pages**. To get an access-token visit: . By default, `picture`, `message`, `story`, `created_time`, `status_type` fields are queried, you can add your own by passing `$field` array as last parameter. You can add `since` and `until` query parameters using `setSince(\Datetime)` and `setUntil(\Datetime)` methods. You can overwrite the default`facebook_page`PinterestBoardFeedCall over `/v1/boards/$boardId/pins/` endpoint. It requires a `$boardId` and an `$accessToken`. To get an access-token visit: [https://developers.pinterest.com/tools/access\_token/](https://developers.pinterest.com/tools/access_token/)`pinterest_board`GithubReleasesFeedCall over `api.github.com/repos/:user/:repo/releases` endpoint. It requires a `$repository` (*user/repository*) and an `$accessToken`. You can add a last `$page` parameter. To get an access-token visit: `github_release`GithubCommitsFeedCall over `api.github.com/repos/:user/:repo/commits` endpoint. It requires a `$repository` (*user/repository*) and an `$accessToken`. You can add a last `$page` parameter. To get an access-token visit: `github_commit`YoutubeMostPopularFeedCall over `googleapis.com/youtube/v3/videos` endpoint with `mostPopular` chart (It’s more kind of an example feed). It requires a `$apiKey` with a valid *Google Cloud Console* account (with not null quota) and *Youtube Data API* enabled.`youtube_playlist_items`YoutubePlaylistItemFeedCall over `googleapis.com/youtube/v3/playlistItems` endpoint. It requires a `$apiKey` with a valid *Google Cloud Console* account (with not null quota) and *Youtube Data API* enabled.`youtube_playlist_items`Modify cache TTL
----------------

[](#modify-cache-ttl)

Each feed-provider which inherits from `AbstractFeedProvider` has access to `setTtl()` method in order to modify the default cache time. By default it is set for `7200` seconds, so you can adjust it to invalidate doctrine cache more or less often.

Create your own feed provider
-----------------------------

[](#create-your-own-feed-provider)

There are plenty of APIs on the internet, and this tool won’t be able to handle them all. But this is not a problem, you can easily create your own feed provider in *mixedfeed*. You just have to create a new *class* that will inherit from `RZ\MixedFeed\AbstractFeedProvider`. Then you will have to implement some methods from `FeedProviderInterface`:

- `getRequests($count = 5): \Generator` method which return a *Guzzle* `Request` generator to be transformed to a response. This is the best option as it will enable **async request pooling**.
- `supportsRequestPool(): bool` method should return if your provider can be pooled to enhance performances. If you are using a third party library to fetch your data (such as some platform SDK), you should set it to `false`.
- `createFeedItemFromObject($item)` method which transform a raw feed object into a canonical `RZ\MixedFeed\Canonical\FeedItem` and `RZ\MixedFeed\Canonical\Image`
- `getDateTime` method to look for the critical datetime field in your feed.
- `getFeed` method to consume your API endpoint with a count limit and take care of caching your responses. This method **must convert your own feed items into `\stdClass` objects, not arrays.**
- `getCanonicalMessage` method to look for the important text content in your feed items.
- `getFeedPlatform` method to get a global text identifier for your feed items.
- then a *constructor* that will be handy to use directly in the MixedFeed initialization.

Feel free to check our existing Feed providers to see how they work. And we strongly advise you to implement a caching system not to call your API endpoints at each request. By default, we use *Doctrine*’s caching system which has many storage options.

### Create a feed provider from a *Doctrine* repository

[](#create-a-feed-provider-from-a-doctrine-repository)

If you need to merge social network feeds with your own website articles, you can create a custom FeedProvider which wraps your Doctrine objects into `\stdClass` items. You’ll need to implement your `getFeed` method using an EntityManager:

```
protected $entityManager;

public function __construct(\Doctrine\ORM\EntityManagerInterface $entityManager)
{
    $this->entityManager = $entityManager;
}

protected function getFeed($count = 5)
{
    return array_map(
        function (Article $article) {
            $object = new \stdClass();
            $object->native = $article;
            return $object;
        },
        $this->entityManager->getRepository(Article::class)->findBy(
            [],
            ['datetime' => 'DESC'],
            $count
        )
    );
}

protected function createFeedItemFromObject($item)
{
    $feedItem = new RZ\MixedFeed\Canonical\FeedItem();
    $feedItem->setDateTime($this->getDateTime($item));
    $feedItem->setMessage($this->getCanonicalMessage($item));
    $feedItem->setPlatform($this->getFeedPlatform());

    for ($item->images as $image) {
        $feedItemImage = new RZ\MixedFeed\Canonical\Image();
        $feedItemImage->setUrl($image->url);
        $feedItem->addImage($feedItemImage);
    }

    return $feedItem;
}
```

Then you can define your *date-time* and *canonical message* methods to look into this object:

```
/**
 * @inheritDoc
 */
public function getDateTime($item)
{
    if ($item->native instanceof Article) {
        return $item->native->getDatetime();
    }

    return null;
}

/**
 * @inheritDoc
 */
public function getCanonicalMessage(stdClass $item)
{
    if ($item->native instanceof Article) {
        return $item->native->getExcerpt();
    }

    return null;
}
```

###  Health Score

44

—

FairBetter than 92% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity43

Moderate usage in the ecosystem

Community21

Small or concentrated contributor base

Maturity75

Established project with proven stability

 Bus Factor1

Top contributor holds 96.9% 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

Every ~84 days

Recently: every ~213 days

Total

37

Last Release

967d ago

Major Versions

v0.3.2 → v1.0.02017-06-13

v1.3.0 → v2.0.02019-02-13

v2.0.4 → v3.0.02019-08-01

v3.2.0 → v4.0.02022-01-21

PHP version history (4 changes)v2.0.0PHP &gt;=7.1

v2.0.1PHP &gt;=7.2

v4.0.0PHP ^7.4 || ^8.0

v4.0.1PHP &gt;=7.4

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/380026?v=4)[Ambroise Maupate](/maintainers/ambroisemaupate)[@ambroisemaupate](https://github.com/ambroisemaupate)

---

Top Contributors

[![ambroisemaupate](https://avatars.githubusercontent.com/u/380026?v=4)](https://github.com/ambroisemaupate "ambroisemaupate (154 commits)")[![glafarge](https://avatars.githubusercontent.com/u/670645?v=4)](https://github.com/glafarge "glafarge (2 commits)")[![DessyRascal](https://avatars.githubusercontent.com/u/28261914?v=4)](https://github.com/DessyRascal "DessyRascal (1 commits)")[![nikossvnk](https://avatars.githubusercontent.com/u/3993858?v=4)](https://github.com/nikossvnk "nikossvnk (1 commits)")[![nlemoine](https://avatars.githubusercontent.com/u/2526939?v=4)](https://github.com/nlemoine "nlemoine (1 commits)")

---

Tags

feed-providersmergephp-librarysocial-networkfeedsocialaggregatorrezo zerosocial networks

###  Code Quality

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/rezozero-mixedfeed/health.svg)

```
[![Health](https://phpackages.com/badges/rezozero-mixedfeed/health.svg)](https://phpackages.com/packages/rezozero-mixedfeed)
```

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M651](/packages/sylius-sylius)[saloonphp/saloon

Build beautiful API integrations and SDKs with Saloon

2.4k9.6M468](/packages/saloonphp-saloon)[kreait/firebase-php

Firebase Admin SDK

2.4k39.7M72](/packages/kreait-firebase-php)[google/gax

Google API Core for PHP

265103.1M454](/packages/google-gax)[googleads/googleads-php-lib

Google Ad Manager SOAP API Client Library for PHP

67410.3M25](/packages/googleads-googleads-php-lib)[pgrimaud/instagram-user-feed

This is a scraper to easily fetch any feed and interact with Instagram (like, follow, etc.) without OAuth for PHP.

940657.1k5](/packages/pgrimaud-instagram-user-feed)

PHPackages © 2026

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