A GETTR.com client library written in PHP with Laravel support.

Overview

Gettr API Clinet PHP

Latest Stable Version Total Downloads License

A GETTR.com client library written in PHP with Laravel support.

This library uses unofficial publicly accessible API endpoints of the website, so keep in mind that some endpoints could stop working anytime. Anyway, open an issue if something is broken or missing.

Installation

Install the package via composer:

$ composer require beeyev/gettr-api-client-php

Optionally, if you use Laravel, you can publish the config file of this package with this command:

$ php artisan vendor:publish --provider="Beeyev\GettrApiClient\Adapters\Laravel\GettrServiceProvider" --tag=config

The following config file will be published in config/gettr.php, set user and token if you want to use methods which require authorization. Read on to find out where to get an authorization token.

return [  
  'user'  => '',  
  'token' => '',  
];

How to obtain the credentials to communicate with Gettr

  1. Authenticate on gettr.com
  2. Open dev tools in browser and find username and token values inside x-app-auth in the HTTP request header of any call to an api.gettr.com endpoint.
Show screenshot

How to use

Example

use Beeyev\GettrApiClient\Gettr;

$user = 'username';  
$token = 'token';  
$gettr = new Gettr($user, $token); //Initial values are optional  
$postData = $gettr->post()->get('p4e8x3'); // Read on to explore all available methods

Or you can just use Laravel facades

$postData = \Gettr::post()->get('p4e8x3'); //Will return an array of raw json
$userPostsData = \Gettr::post()->getUserPosts('enzo20');

API methods using Laravel facades:

Posts

//Get a post
Gettr::post()->get(string $postId);

//Deletes user's post
Gettr::post()->delete(string $postId);

//Make a repost
Gettr::post()->repost(string $postId);

//Undo a repost
Gettr::post()->undoRepost(string $postId);

//Get a user's posts
Gettr::post()->getUserPosts(string $username, int $offset = 0, int $maximum = 20, string $direction = 'rev');

//Get a user's replies
Gettr::post()->getUserReplies(string $username, int $offset = 0, int $maximum = 20, string $direction = 'rev');

//Returns a user's media
Gettr::post()->getUserMedia(string $username, int $offset = 0, int $maximum = 20, string $direction = 'rev');

//Returns a list of posts which were liked by a user
Gettr::post()->getPostsLikedByUser(string $username, int $offset = 0, int $maximum = 20, string $direction = 'rev');

//Returns a list of users who liked a post
Gettr::post()->getUsersLikedPost(string $postId, int $offset = 0, int $maximum = 20, string $direction = 'rev');

//Returns a list of users who reposted a post
Gettr::post()->getUsersRepostedPost(string $postId, int $offset = 0, int $maximum = 20, string $direction = 'rev');

//Returns a post's comments.
Gettr::post()->comments(string $postId, int $offset = 0, int $maximum = 20, string $direction = 'rev');

//Searches posts with a phrase
Gettr::post()->search(string $query, int $offset = 0, int $maximum = 20);

//Pins a specified post
//This will pin a post at the top of your profile and replace any previously pinned
Gettr::post()->pin(string $postId);

//Create a new post
//Unfortunately I did not have enough time to figure it out how this API method should work.
//Quote post and Reply methods work the same, so this is why I did not even try to implement them.
//I will appreciate if smb would help me with this.
//Gettr::post()->create(string $text);

Likes

//Like a post
//The result will also contain total number of likes but only when you make a change
Gettr::like()->likePost(string $postId);

//Unlike a post
Gettr::like()->unlikePost(string $postId);

//Like a comment.
Gettr::like()->likeComment(string $commentId);

//Unlike a comment
Gettr::like()->unlikeComment(string $commentId);

//Get all posts liked by a user
Gettr::like()->getPostsLikedByUser(string $username);

Users

//Get User information
Gettr::user()->info(string $username);

//Follow a user
Gettr::user()->follow(string $username);

//Unfollow a user
Gettr::user()->unfollow(string $username);

//Mute a user
Gettr::user()->mute(string $username);

//Unmute a user
Gettr::user()->unmute(string $username);

//Returns list of muted users. ! Require authorisation
Gettr::user()->getMutes(int $offset = 0, int $maximum = 20);

//Block a user. ! Require authorisation
Gettr::user()->block(string $username);

//Unblock a user. ! Require authorisation
Gettr::user()->unblock(string $username);

//Returns list of blocked users. ! Require authorisation
Gettr::user()->getBlocked(int $offset = 0, int $maximum = 20);

//Searches users
Gettr::user()->search(string $query,  int $offset = 0, int $maximum = 20);

//Check if Username exists
Gettr::user()->checkIfUsernameExists(string $username);

//Returns list of user follows.
Gettr::user()->followings(string $username, int $offset = 0, int $maximum = 20);

//Returns a list of user followers.
Gettr::user()->followers(string $username, int $offset = 0, int $maximum = 20);

//Returns current user's timeline, (same thing what you see on the home page)
Gettr::user()->timeline(int $offset = 0, int $maximum = 20, string $direction = 'rev');

Suggestions

//Returns a list of suggested users.
Gettr::suggested()->users(int $offset = 0, int $maximum = 20);

//Returns a list of suggested hashtags.
Gettr::suggested()->hashtags(int $offset = 0, int $maximum = 20);

Testing

¯_(ツ)_/¯

License

The MIT License (MIT). Please see License File for more information.

You might also like...
A sampling profiler for PHP written in PHP, which reads information about running PHP VM from outside of the process.

Reli Reli is a sampling profiler (or a VM state inspector) written in PHP. It can read information about running PHP script from outside of the proces

A sampling profiler for PHP written in PHP, which reads information about running PHP VM from outside of the process.

Reli Reli is a sampling profiler (or a VM state inspector) written in PHP. It can read information about running PHP script from outside of the proces

A simple twitter-feed-style RSS aggregator written in PHP, Laravel, Inertia.js, Tailwind and Vue.js
A simple twitter-feed-style RSS aggregator written in PHP, Laravel, Inertia.js, Tailwind and Vue.js

RSS A simple, opinionated, RSS feed aggregator. Features The following features are built into the application: Supports RSS and ATOM formats. Regular

A multithreaded application server for PHP, written in PHP.

appserver.io, a PHP application server This is the main repository for the appserver.io project. What is appserver.io appserver.io is a multithreaded

A status monitor for Elite Dangerous, written in PHP. Designed for 1080p screens in the four-panel-view in panel.php, and for 7 inch screens with a resolution of 1024x600 connected to a Raspberry Pi.

EDStatusPanel A status monitor for Elite Dangerous, written in PHP. Designed for 1080p screens in the four-panel-view in panel.php, and for 7 inch scr

PHP generics written in PHP

PHP generics written in PHP Require PHP = 7.4 Composer (PSR-4 Autoload) Table of contents How it works Quick start Example Features Tests How it work

A PHP parser written in PHP

PHP Parser This is a PHP 5.2 to PHP 8.1 parser written in PHP. Its purpose is to simplify static code analysis and manipulation. Documentation for ver

A beautiful, fully open-source, tunneling service - written in pure PHP
A beautiful, fully open-source, tunneling service - written in pure PHP

Expose A completely open-source ngrok alternative - written in pure PHP. Documentation For installation instructions, in-depth usage and deployment de

Websocket chat room written in PHP based on workerman.

基于workerman的GatewayWorker框架开发的一款高性能支持分布式部署的聊天室系统。

Comments
  • Uncaught Error: Class 'Beeyev\GettrApiClient\Gettr' not found

    Uncaught Error: Class 'Beeyev\GettrApiClient\Gettr' not found

    I get the error:

    PHP Fatal error:  Uncaught Error: Class 'Beeyev\GettrApiClient\Gettr' not found in /home/lifeboat/read.gettr.feed.and.retweet.a.popular.tweet.php:8
    Stack trace:
    #0 {main}
      thrown in /home/lifeboat/read.gettr.feed.and.retweet.a.popular.tweet.php on line 8
    

    My code is:

    <?php
    
    use Beeyev\GettrApiClient\Gettr;
    
    $user = 'lifeboathq';
    $token = 'stuff';
    $gettr = new Gettr($user, $token); //Initial values are optional
    $postData = $gettr->post()->get('p6pd36'); // Read on to explore all available methods
    
    print $postData;
    

    Note that I'm not getting an error with the use command. I installed the library with composer require beeyev/gettr-api-client-php

    opened by lifeboatpres 3
Releases(1.0.2)
Owner
null
Michael Pratt 307 Dec 23, 2022
The Assure Alliance support website. This website is based on Questions2Answers and is a forum for support using Biblical Tools

The Assure Alliance support website. This website is based on Questions2Answers and is a forum for support using Biblical Tools

United Bible Societies Institute for Computer Assisted Publishing 3 Jul 29, 2022
MOFHY Lite is a priceless MyOwnFreeHost Client Area for account management, ticket support system and a free ssl service

MOFHY Lite is a priceless MyOwnFreeHost Client Area for account management, ticket support system and a free ssl service. It has easy to use features much like the WHMCS Digit UI interface.

MOFHY Developers 1 Oct 21, 2022
PHP library providing retry functionality with multiple backoff strategies and jitter support

PHP Backoff Easily wrap your code with retry functionality. This library provides: 4 backoff strategies (plus the ability to use your own) Optional ji

Signature Tech Studio 145 Dec 21, 2022
Stringy - A PHP string manipulation library with multibyte support, performance optimized

Stringy - A PHP string manipulation library with multibyte support, performance optimized

Lars Moelleken 145 Jan 1, 2023
A PHP library to support implementing representations for HATEOAS REST web services.

Hateoas A PHP library to support implementing representations for HATEOAS REST web services. Installation Working With Symfony Usage Introduction Conf

William Durand 998 Dec 5, 2022
Tiny PHP library providing retry functionality with multiple backoff strategies and jitter support

JBZoo / Retry 4 retry strategies (plus the ability to use your own) Optional jitter / randomness to spread out retries and minimize collisions Wait ti

JBZoo Toolbox 6 Dec 19, 2022
Small Library to Serve Images in PHP in a Better Way (Resize, Compress) with Caching Support

A library for serving images and optimizing, changing their sizes, this library uses the caching feature, and in addition, it is very fast and small in size. In addition to these features, this library also optimizes images.

Developix 9 Oct 18, 2022
PHP client library for Coveralls API.

php-coveralls PHP client library for Coveralls. Prerequisites PHP 5.5+ for 2.x or 5.3+ for 1.x On GitHub Building on Travis CI, CircleCI, Jenkins or C

null 514 Dec 25, 2022
🌐 A minimalist languages library that made plugins support multiple languages.

libLanguages · libLanguages is a PocketMine-MP library for making plugins support multiple languages. Easy To Learn: Just declare it in onEnable() fun

thebigcrafter 1 May 1, 2022