Skip to content

Post Request

Ben Sherred edited this page Nov 5, 2021 · 4 revisions

Introduction

Companies have a news feature which is made up of posts. To get the information about a post, you can execute the following code.

Getting a Post

To get the information about a post, you can call the post(int $id) method on an instance of CompanyRequest. This will return an instance of CompanyPost.

<?php

require_once('vendor/autoload.php');

$client = new TruckersMP\APIClient();
$pst = $client->company(17)->role(121)->get(); // This is an instance of `CompanyPost`

Available Methods

The CompanyPost model has a couple of methods to get additional information about the company role.

Method Listing

getId()

The getId method returns the ID of the post.

$post = $client->company(17)->role(121)->get();

echo 'The ID of this post is ' . $post->getId();

getTitle()

The getTitle method returns the title of the post.

$post = $client->company(17)->post(121)->get();

echo $post->getTitle();

getSummary()

The getSummary method returns a summary of the post.

$post = $client->company(17)->post(121)->get();

echo 'Post summary: ' . $member->getSummary();

getContent()

The getContent method returns the content of the post.

$post = $client->company(17)->post(121)->get();

echo $post->getContent();

getAuthor()

The getAuthor method returns the name of the author who made the post.

$post = $client->company(17)->post(121)->get();

echo 'Author: ' . $post->getAuthor();

getAuthorId()

The getAuthorId method returns the ID of the author who wrote the post.

$post = $client->company(17)->post(121)->get();

echo 'The ID of the author is ' . $post->getAuthorId();

isPinned()

The isPinned method returns whether or not the post is pinned to the companies page.

$post = $client->company(17)->post(121)->get();

if ($post->isPinned()) {
    echo 'This post is pinned';
} else {
    echo 'This post is not pinned';
}