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.0Roadmap
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- Fork it!
- Create your feature branch: git checkout -b my-new-feature
- Commit your changes: git commit -am 'Add some feature'
- Push to the branch: git push origin my-new-feature
- 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