PHP code example of beeyev / gettr-api-client-php

1. Go to this page and download the library: Download beeyev/gettr-api-client-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/ */

    

beeyev / gettr-api-client-php example snippets


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

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

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

//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);



//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);

//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');

//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);
bash
$ composer