PHP code example of magium / mcm-twitter

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

    

magium / mcm-twitter example snippets




$magiumFactory = new \Magium\Configuration\MagiumConfigurationFactory();
$twitterFactory = new \Magium\ConfigurationManager\Twitter\TwitterFactory($magiumFactory->getConfiguration());

$twitter = $twitterFactory->factory();
$timeline = $twitter->get(
    \Magium\ConfigurationManager\Twitter\Constants::GET_STATUSES_USER_TIMELINE
);

foreach ($timeline as $tweet) {
    echo $tweet->text . "\n";
}




$opts = getopt('', [
    'tweet::'
]);
if (!isset($opts['tweet']) || !$opts['tweet']) {
    echo "Please provide a tweet with --tweet\n";
    exit;
}

$magiumFactory = new \Magium\Configuration\MagiumConfigurationFactory();
$twitterFactory = new \Magium\ConfigurationManager\Twitter\TwitterFactory($magiumFactory->getConfiguration());

$twitter = $twitterFactory->factory();
$result = $twitter->post(
    \Magium\ConfigurationManager\Twitter\Constants::POST_STATUSES_UPDATE, ['status' => $opts['tweet']]
);

var_dump($result);