PHP Client of Utopian API

PHP Client of Utopian API

  • What is the project about?
    The project is to wrap the public utopian APIs in PHP Class. I have seen @emrebeyler 's contribution on Python client, so I think it is a good idea to provide a PHP implementation.

  • Technology Stack
    PHP 7.0

  • Roadmap
    The next release will be adding more unit tests and more about moderators in terms of rewards, payout etc.

  • How to contribute?
    Github: https://github.com/DoctorLai/utopian-api-php-client

    1. Fork it!
    2. Create your feature branch: git checkout -b my-new-feature
    3. Commit your changes: git commit -am 'Add some feature'
    4. Push to the branch: git push origin my-new-feature
    5. Submit a pull request :D

Installation and Usage

You just need to git clone the project and reference the unit

require('class.utopian.php');

Creating Instance

$utopian = new Utopian();

Getting a list of moderators

$moderators = $utopian->GetModerators()

Check if account is moderator type

if ($utopian->IsModerator('justyy')) echo "Hello, yes!";

Check if account is sponsor type

if ($utopian->IsSponsor('justyy')) echo "Hello, i am sponsor!";

Get List of Sponsors

print_r($utopian->GetSponsors());

Get Approved posts

foreach ($utopian->GetPosts() as $post) {
   // do something about $post;
}

Get a list of Hidden Posts

$flagged_posts = $utopian->GetPosts(array("status" => "flagged"));

Get count of approved contribution

echo "Total approved: " . $utopian->GetCount();

Get Post detail

var_dump($utopian->GetPost('justyy', 'string-contains-test-cannot-be-added-to-the-post'));

Check if bot is voting

if ($utopian->IsBotVoting()) {
 // ok write a post
}

Unit Tests

The unit tests framework is phpunit and you can run tests via command phpunit



Posted on Utopian.io - Rewarding Open Source Contributors

H2
H3
H4
3 columns
2 columns
1 column
Join the conversation now
Logo
Center