Download the PHP package thecodingcompany/php-mastodon without Composer
On this page you can find all versions of the php package thecodingcompany/php-mastodon. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download thecodingcompany/php-mastodon
More information about thecodingcompany/php-mastodon
Files in thecodingcompany/php-mastodon
Package php-mastodon
Short Description Mastodon PHP library oAuth and API
License MIT
Homepage https://github.com/TheCodingCompany/MastodonOAuthPHP
Informations about the package php-mastodon
MastodonOAuthPHP
PHP Library for Mastodon REST API
What's in it?
- App creation.
- Full oAuth implementation to authorize your App by users.
- Create and get authorization token, access token, client_id, client_secret and bearer token.
- Authenticate users
- Get user information
- Get user followers and following
- Get user status
- Post status update
Installation using Composer
Questions and example?
Yes, mail me at: vangelier at hotmail dot com Contact me on #Twitter @digital_human Contact me on #Mastodon https://mastodon.social/@digitalhuman
Get started
Step 1
First step is you need to create a so called App. This app represents your 'service'. With this app you provide services to users or use Mastodon for other reasons.
To create an App is as simple as:
The parameter now has your 'client_id' and 'client_secret'. This information is important for the rest of your life ;). Store it in a file, DB or array. You need this everytime you communicate with Mastodon.
Step 2
Now you (your app) wants to provide services to a user. For this the user needs to authorize your app. Else you can't help him/her. To do this you need to redirect the user, with your tokens to Mastodon and ask for permission so to say. And example:
Step 3
So you now have 3 tokens. The client_id, client_secret and the users access_token. Now exchange the access token for a bearer token and you are done. Save these tokens!
Step 4
To then post a status, you just do this: