1. Go to this page and download the library: Download mpratt/simple-lifestream 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/ */
mpratt / simple-lifestream example snippets
$lifestream = new \SimpleLifestream\SimpleLifestream();
$streams = array(
new \SimpleLifestream\Stream('Reddit', 'mpratt'),
new \SimpleLifestream\Stream('Github', 'mpratt'),
new \SimpleLifestream\Stream('Youtube', 'ERB'),
new \SimpleLifestream\Stream('StackOverflow', '430087'),
new \SimpleLifestream\Stream('FacebookPages', '27469195051'),
new \SimpleLifestream\Stream('Feed', 'http://www.michael-pratt/blog/rss/'),
);
$lifestream = new \SimpleLifestream\SimpleLifestream();
$lifestream->loadStreams($streams);
$data = $lifestream->getLifestream();
foreach ($data as $d) {
echo $d['html'];
}
$config = array(
'date_format' => 'Y-m-d H:i', // Date format returned on by the streams
'link_format' => '<a href="{url}">{text}</a>', // Link template used by the streams
'language' => 'English', // The Output language
'cache_ttl' => (60*10), // Optional: Duration of the cache in seconds
'cache_dir' => '/path/bla/bla', // Optional: A place where the cache should be stored
);
$lifestream = new \SimpleLifestream\SimpleLifestream($config);
$config = array(
'language' => 'Spanish',
);
$streams = array(
new \SimpleLifestream\Stream('Reddit', 'mpratt'),
new \SimpleLifestream\Stream('Github', 'mpratt'),
);
$lifestream = new \SimpleLifestream\SimpleLifestream($config);
$data = $lifestream->loadStreams($streams)->getLifestream();
foreach ($data as $d) {
echo $d['html'];
}
$streams = array(
new \SimpleLifestream\Stream('Github', 'mpratt'),
new \SimpleLifestream\Stream('Youtube', 'ERB'),
);
$streams = array(
new \SimpleLifestream\Stream('Github', array('resource' => 'mpratt')),
new \SimpleLifestream\Stream('Youtube', array('resource' => 'ERB')),
);
$data = $lifestream->getLifestream();
if ($lifestream->hasErrors()) {
echo $lifestream->getLastError();
}
if ($lifestream->hasErrors()) {
var_dump($lifestream->getErrors());
}
$streams = array(
new \SimpleLifestream\Stream('Reddit', array(
'resource' => 'mpratt',
'callback' => function ($value) {
return array(
'modified_title' => str_replace(' ', '-', $value['data']['title'])
);
},
)),
new \SimpleLifestream\Stream('Github', 'mpratt'),
new \SimpleLifestream\Stream('Youtube', 'ERB'),
);
$lifestream = new \SimpleLifestream\SimpleLifestream();
$output = $lifestream->loadStreams($streams)->getLifestream();
print_r($output);
$reddit = new \SimpleLifestream\Stream('Reddit', 'mpratt');
$reddit->addCallback(function ($v) {
return array(
'modified_title' => str_replace(' ', '', $v['data']['title'])
);
});
$streams = array(
$reddit,
new \SimpleLifestream\Stream('Github', 'mpratt'),
new \SimpleLifestream\Stream('Youtube', 'ERB'),
);
$lifestream = new \SimpleLifestream\SimpleLifestream();
$output = $lifestream->loadStreams($streams)->getLifestream();
print_r($output);
// Tell the library to Ignore all favorited actions/types
$lifestream->ignore('favorited');
$data = $lifestream->getLifestream();
// Tell the library to Ignore all starred actions/types only from the Github Provider
$lifestream->ignore('favorited', 'Github');
$data = $lifestream->getLifestream();
$config = array();
$streams = array(
new \SimpleLifestream\Stream('Reddit', 'mpratt')
);
$lifestream = new \SimpleLifestream\SimpleLifestream($config);
$lifestream = new \SimpleLifestream\Formatters\HtmlList($lifestream);
$lifestream->loadStreams($streams);
echo $lifestream->getLifestream(4);
/* This prints something around this lines:
<ul class="simplelifestream">
<li class="servicename">Y-m-d H:i - <a href="...">text 1</a></li>
<li class="servicename">Y-m-d H:i - <a href="...">text 2</a></li>
<li class="servicename">Y-m-d H:i - <a href="...">text 3</a></li>
<li class="servicename">Y-m-d H:i - <a href="...">text 4</a></li>
</ul>
*/
$lifestream = new \SimpleLifestream\Formatters\Template(new \SimpleLifestream\SimpleLifestream());
$lifestream->setTemplate('<div class="{service}">{text} {link}</div>');
echo $lifestream->loadStreams($streams)->getLifestream();
/* This prints something round this lines:
<div class="servicename">a text <a href="..">a link</a></div>
<div class="servicename">another text <a href="..">a link</a></div>
<div class="servicename">and more text <a href="..">a link</a></div>
*/
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.