PHP Client implementation of public Utopian API. The basic class is Utopian
which Moderators
, Stats
and Sponsors
extend.
Install composer if you don't already have it.
sudo apt-get install composer
You just need to git clone
the project and reference the unit.
cd utopian-api-php-client
Once in the repo's directory, run composer install for the dependencies:
composer install
You can then test all tests using this command: (Only if the files in the directory end in Test.php with a capital 'T')
vendor/phpunit/phpunit/phpunit tests
Or if you want to test one at a time, do this:
vendor/phpunit/phpunit/phpunit UnitTest tests/sponsors_Test.php
require('class.utopian.php');
If you just need Moderators
you can do this instead:
require('class.moderators.php');
If you just need Sponsors
you can do this instead:
require('class.sponsors.php');
If you just need Stats
you can do this instead:
require('class.stats.php');
$utopian = new Utopian();
$moderators = new Moderators();
$sponsors = new Sponsors();
$stats = new Stats();
$moderators = $utopian->GetModerators()
if ($utopian->IsModerator('justyy')) echo "Hello, yes!";
if ($utopian->IsSponsor('justyy')) echo "Hello, i am sponsor!";
print_r($utopian->GetSponsors());
foreach ($utopian->GetPosts() as $post) {
// do something about $post;
}
$flagged_posts = $utopian->GetPosts(array("status" => "flagged"));
echo "Total approved: " . $utopian->GetCount();
var_dump($utopian->GetPost('justyy', 'string-contains-test-cannot-be-added-to-the-post'));
if ($utopian->IsBotVoting()) {
// ok write a post
}
This will re-fetch the data from Utopian API.
$moderators->Reload();
$moderators->GetRawData();
print_r($moderators->GetList());
echo "there are " . $moderators->GetTotal() . " moderators.";
$justyy = $moderators->GetModerator('justyy');
print_r($justyy);
echo "Total Paid Rewards: " . $moderators->GetTotalPaidRewards();
echo "Should Receive Total: " . $moderators->GetShouldReceiveRewards();
echo "Total Moderated Count: " . $moderators->GetTotalModerated();
echo "Steem: " . $moderators->GetTotalPaidRewardsSteem();
foreach ($moderators->GetListOfSuperModerators() as $acc) {
echo "Boss: " . $acc;
}
foreach ($moderators->GetListOfApprentice() as $acc) {
echo "Student: " . $acc;
}
foreach ($moderators->GetListOfBannedModerators() as $acc) {
echo "Banned: " . $acc;
}
foreach ($moderators->GetListOfActiveModerators() as $acc) {
echo "Active: " . $acc;
}
This will re-fetch the data from Utopian API.
$sponsors->Reload();
$sponsors->GetRawData();
print_r($sponsors->GetList());
echo "there are " . $sponsors->GetTotal() . " sponsors.";
$ned = $sponsors->GetSponsor('ned');
print_r($ned);
echo "Total Paid Rewards: " . $sponsors->GetTotalPaidRewards();
echo "Should Receive Total: " . $sponsors->GetShouldReceiveRewards();
echo "Steem: " . $sponsors->GetTotalPaidRewardsSteem();
echo "Total Vesting by all sponsors: " . $sponsors->GetTotalVesting();
foreach ($sponsors->GetListOfWitness() as $acc) {
echo "Witness: " . $acc;
}
echo "Total Paid Rewards Steem: " . $sponsors->GetTotalPaidRewardsSteem();
foreach ($sponsors->GetListOfOptedOutSponsors() as $acc) {
echo "Opted_out: " . $acc;
}
This will re-fetch the data from Utopian API.
$stats->Reload();
$stats->GetRawData();
print_r($stats->GetCategories());
$blog = $stats->GetCategory('blog');
if ($blog) {
echo $blog->total_images;
}
Possible values: _id, total_paid_rewards, total_pending_rewards, total_paid_authors, total_paid_curators, __v, stats_moderator_shares_last_check, stats_sponsors_shares_last_check, stats_total_pending_last_check, stats_total_paid_last_check, stats_paid_moderators_last_check, stats_paid_sponsors_last_check, stats_categories_last_check, stats_last_updated_posts, bot_is_voting, last_limit_comment_benefactor, stats_total_pending_last_post_date, stats_total_paid_last_post_date, stats_total_moderated
echo $stats->GetValue('bot_is_voting');
Possible key attributes (second parameter): average_tags_per_post, total_tags, average_links_per_post, total_links, average_images_per_post, total_images, average_posts_length, total_posts_length, average_paid_curators, total_paid_curators, average_paid_authors, total_paid_authors, total_paid, average_likes_per_post, total_likes, total_posts
echo $stats->GetCategoryValue('blog', 'total_tags');
This method will return array (key-value pairs) for given attribute. For example, the following sums up all total_links
in all categories.
$x = array_values($stats->GetCategoryValueArray("total_links"));
echo array_sum($x);