-
Notifications
You must be signed in to change notification settings - Fork 15
Posts Request
Ben Sherred edited this page Nov 5, 2021
·
4 revisions
You can get all the posts for a company by executing the following code.
To get the posts for a company, you can call the posts()
method on the CompanyRequest
. This will return an instance of PostCollection
.
<?php
require_once('vendor/autoload.php');
$client = new TruckersMP\APIClient();
$posts = $client->company(1)->posts()->get(); // This is instance of `PostCollection`
You can then loop through the posts to get information about a specific post. For more information, check out the available methods on the Post Request page.
$posts = $client->company(1)->posts()->get();
$count = 0;
foreach ($posts as $post) {
$count++;
}
echo "This company has {$count} posts";
If you have any questions about the library, you can create a topic on our forum.
This package is open-source and is licensed under the MIT license.