PHP code example of polidog / esa-php
1. Go to this page and download the library: Download polidog/esa-php 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/ */
polidog / esa-php example snippets
# Install Composer
curl -sS https://getcomposer.org/installer | php
composer.phar
= \Polidog\Esa\Api::factory("<access_token>", "foobar");
$api->user();
// GET /v1/user
$api->teams();
// GET /v1/teams
$api->team('bar');
// GET /v1/teams/bar
$api->stats()
// GET /v1/teams/foobar/stats
$api->members();
// GET /v1/teams/foobar/members
$api->posts();
// GET /v1/teams/foobar/posts
$api->posts(["q" => "in:help"]);
// GET /v1/teams/foobar/posts?q=in%3Ahelp
$api->createPost(["name" => "foo"]);
// POST /v1/teams/foobar/posts
$api->updatePost(1, ["name" => "bar"]);
// PATCH /v1/teams/foobar/posts/1
$api->deletePost(1);
// DELETE /v1/teams/foobar/posts/1
// Comment API
$api->comments(1); /* post number */
// GET /v1/teams/foobar/posts/1/comments
$api->createComment(1, ['body_md' => 'baz']);
// POST /v1/teams/foobar/posts/1/comments
$api->comment(123); /* comment id */
// GET /v1/teams/foobar/comments/123
$api->updateComment(123, ['body_md' => 'bazbaz']);
// PATCH /v1/teams/foobar/comments/123
$api->deleteComment(123);
// DELETE /v1/teams/foobar/comments/123
$api->comments();
// GET /v1/teams/foobar/comments
$api->createSharing(1);
// POST /v1/teams/foobar/posts/1/sharing
$api->deleteSharing(1);
// DELETE /v1/teams/foobar/posts/1/sharing
# Star API
$api->postStargazers(1);
// GET /v1/teams/foobar/posts/1/stargazers
$api->addPostStar(1);
// POST /v1/teams/foobar/posts/1/star
$api->deletePostStar(1);
// DELETE /v1/teams/foobar/posts/1/star
$api->commentStargazers(123);
// GET /v1/teams/foobar/comments/123/stargazers
$api->addCommentStar(123);
// POST /v1/teams/foobar/comments/123/star
$api->deleteCommentStar(123);
// DELETE /v1/teams/foobar/comments/123/star
# Watch API
$api->watchers(1);
// GET /v1/teams/foobar/posts/1/watchers
$api->addWatch(1);
// POST /v1/teams/foobar/posts/1/watch
$api->deleteWtach(1);
// DELETE /v1/teams/foobar/posts/1/watch
# Categories API
$api->categories();
// GET /v1/teams/foobar/categories
# Tags API
$api->tags();
// GET /v1/teams/foobar/tags
# Invitation API
$api->invitation();
// GET /v1/teams/foobar/invitation
$api->regenerateInvitation();
// POST /v1/teams/foobar/invitation_regenerator
$api->pendingInvitations();
// GET /v1/teams/foobar/invitations
$api->sendInvitation(['[email protected] ','[email protected] ']);
// POST /v1/teams/foobar/invitations
$api->cancelInvitation($code);
// DELETE /v1/teams/foobar/invitations/baz
# Emoji API
$api->emojis();
// GET /v1/teams/foobar/emojis
$api->createEmoji(['code' => 'team_emoji', image: '/path/to/image');
// POST /v1/teams/foobar/emojis
$api->createEmoji(['code' => 'alias_code', origin_code: 'team_emoji');
// POST /v1/teams/foobar/emojis
$api->deleteEmoji('team_emoji');
// DELETE /v1/teams/foobar/emojis/team_emoji