PHP Client of Utopian API


The project is to wrap the public utopian APIs in PHP Class. Technology Stack: PHP 7.0. 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 😀

Installation and Usage

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

1
require('class.utopian.php');
require('class.utopian.php');

Creating Instance

1
$utopian = new Utopian();
$utopian = new Utopian();

Getting a list of moderators

1
$moderators = $utopian->GetModerators()
$moderators = $utopian->GetModerators()

Check if account is moderator type

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

Check if account is sponsor type

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

Get List of Sponsors

1
print_r($utopian->GetSponsors());
print_r($utopian->GetSponsors());

Get Approved posts

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

Get a list of Hidden Posts

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

Get count of approved contribution

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

Get Post detail

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

Check if bot is voting

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

Unit Tests

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

–EOF (The Ultimate Computing & Technology Blog) —

GD Star Rating
loading...
403 words
Last Post: Being part of Utopian Moderating Team is Great ! (Intro Post)
Next Post: Adding Moderators Class to PHP Client of Utopian API

The Permanent URL is: PHP Client of Utopian API

Leave a Reply