PHP code example of mathieumaingret / socialstream

1. Go to this page and download the library: Download mathieumaingret/socialstream 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/ */

    

mathieumaingret / socialstream example snippets




$posts = array();
$nbPosts = 8;
$accountName = 'accountName';
$cacheDuration = 10; // Cache expires after 10 min

$media = new \SocialStream\Media\Twitter();
if ($media->isAuthorized()) {
    $media->setAccount($accountName);
    $media->setCacheExpiration($cacheDuration);
    $posts = $media->getLastPosts($nbPosts);
}
var_dump($posts);

$nbPosts = 8; // nb posts for each media
$posts = array();
$mediasTypes = array(
    'facebook' => '',
    'twitter' => ''
);
$socialWall = new \SocialStream\Wall($mediasTypes, $nbPosts);

$socialWall->shufflePosts(); // If you want to display your posts randomly

$posts = $socialWall->getPosts();
foreach($posts as $post) {
    echo $post->id;
}

composer dump-autoload