Download the PHP package afterlogic/mastodon-api without Composer

On this page you can find all versions of the php package afterlogic/mastodon-api. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package mastodon-api

Mastodon API PHP

PHP wrapper for the Mastodon API that includes oAuth helpers, Guzzle based.

Build Status

Getting started

Install it via Composer.

Mastodon API and instances

This is a plain API wrapper, so the intention is to support further changes in the API by letting the developer pass the desired endpoint.

  1. Get the REST Mastodon documentation.
  2. Get an instance from the instance list.

Quick test

oAuth

An interactive demo is available.

  1. Clone the GitHub repository.
  2. cd in the cloned directory
  3. Run composer install
  4. Run php -S localhost:8000
  5. In your browser, go to http://localhost:8000/test_oauth.php
  6. You will get the client_id and client_secret, click on the authorization URL link, then confirm the authorization under Mastodon and copy the authorization code.
  7. Get the bearer: click on the "Get access token" button.
  8. Authenticate with your Mastodon username (email) and password: click on "Login".

Mastodon API

  1. Make your own copy of _testcredentials.example.php as _testcredentials.php
  2. Define in _testcredentials.php the information obtained with oAuth and your Mastodon email and password.
  3. In your browser, go to http://localhost:8000/test_api.php

Authenticate with oAuth

Register your application

Give it a name and an optional instance. The instance defaults to mastodon.social.

The default configuration is limited the the 'read' and 'write' scopes. You can modify it via

Note that this must be done while obtaining the token so you cannot override this after. More about scopes.

Get the authorization code

  1. Get the authorization URL $authorizationUrl = $oAuth->getAuthorizationUrl();
  2. Go to this URL, authorize and copy the authorization code.

Get the bearer

  1. Store the authorization code in the configuration value object. $oAuth->config->setAuthorizationCode(xxx);

  2. Then get the access token. As a side effect, stores it on the configuration value object. $oAuth->getAccessToken();

Use the Mastodon API

Instantiate the Mastodon API with the configuration

The oAuth credentials should be stored from the configuration value object for later retrieval. Then you can use it in this way.

User login

Login with Mastodon email and password. $oAuth->authenticateUser($email, $password);

Use the API wrapper

Here are a few examples of the API wrapper usage. Read the full documentation.

Get

Get credentials

Get followers

Post

Clear notifications

@todo complete with delete and stream.


All versions of mastodon-api with dependencies

PHP Build Version
Package Version
Requires php Version >=5.6.0
guzzlehttp/guzzle Version ^7.4.5
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package afterlogic/mastodon-api contains the following files

Loading the files please wait ....