1. Go to this page and download the library: Download rezozero/mixedfeed library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
rezozero / mixedfeed example snippets
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, // itsFeed(
'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);
new MixedFeed([…], MixedFeed::ASC);
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;
}
/**
* @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;
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.