PHP code example of thecodingcompany / php-mastodon
1. Go to this page and download the library: Download thecodingcompany/php-mastodon 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/ */
thecodingcompany / php-mastodon example snippets
composer
/**
* Intellectual Property of #Mastodon
*
* @copyright (c) 2017, #Mastodon
* @author V.A. (Victor) Angelier <[email protected]>
* @version 1.0
* @license http://www.apache.org/licenses/GPL-compatibility.html GPL
*
*/
ial tokens to a file, so you don't lose them
file_put_contents('mastodon_creds', $serializedData); // this will save it in the same folder as this file
/**
* Intellectual Property of #Mastodon
*
* @copyright (c) 2017, #Mastodon
* @author V.A. (Victor) Angelier <[email protected]>
* @version 1.0
* @license http://www.apache.org/licenses/GPL-compatibility.html GPL
*
*/
ain and provide the library with your App's client_id and secret.
*/
$t->setMastodonDomain("mastodon.social"); // Set the mastodon domain, you can remove this line if you're using mastodon.social as it's the default
$t->setCredentials($recoveredArray); // use the keys from the file we stored in Step 1
/**
* Now that is set we can get the Authorization URL and redirect the user to Mastodon
* After the user approves your App, it will return with an Access Token.
*/
$auth_url = $t->getAuthUrl();
header("Location: {$auth_url}", true);
exit;
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.