Welcome to the official PHP SDK for JustPush! This SDK allows you to easily integrate with our powerful messaging platform, providing functionalities to create messages, retrieve messages, create topics, and update topics.
- Create Messages: Send messages effortlessly using our streamlined API.
- Retrieve Messages: Fetch messages with ease for seamless integration and processing.
- Create Topics: Organize your messages by creating specific topics.
- Update Topics: Modify existing topics to keep your message structure flexible and up-to-date.
Install the SDK via Composer:
composer require justpush/justpush-php-sdk
This is a basic example of sending a notification.
$response = JustPushMessage::token('REPLACE_WITH_USER_TOKEN')
->message('Here is a sample Message')
->title('Test Title')
->create();
echo json_encode($response->result(), JSON_PRETTY_PRINT); //Result
echo json_encode($response->responseHeaders(), JSON_PRETTY_PRINT); //Response Headers| Function Name | Available Attributes | Description |
|---|---|---|
token |
string $token |
Set the user token / API token |
message |
string $message |
The textual body of the message |
title |
string $title |
The title of the message |
topic |
string $topic |
Either the UUID or the name of the topic you want to send the message to |
image |
string $url, ?string $caption |
Adds an image the to the message |
images |
array $images |
Adds multiple images |
button |
string $cta, string $url, bool $actionRequired |
Adds a button to the message |
buttons |
array $buttons |
Adds multiple buttons to the message |
sound |
string $sound |
Define the sound of the message |
priority |
int $priority |
Manually set the priority, 2, 1, 0, -1, -2 |
highestPriority |
Set the message priority on 2 |
|
highPriority |
Set the message priority on 1 |
|
normalPriority |
Set the message priority on 0 |
|
lowPriority |
Set the message priority on -1 |
|
lowestPriority |
Set the message priority on -2 |
|
expiry |
int $expiry |
Set the expiry in Seconds |
acknowledge |
bool $requiresAcknowledgement, bool $requiresRetry = false, int $retryInterval = 0, int $maxRetries = 0, bool $callbackRequired = false, ?string $callbackUrl = null, ?array $callbackParams = null |
Adds an acknowledgement to the messages |
Our goals it to keep the API as simple as possible. Therefore, you can send either:
- Topic Title - When the title exists more than once, the oldest topic will be used. If the name is not in your topic list, a new topic will be created.
- Topic UUID - Uses the exact match of the topic
When a message contains multiple images, the first image will be used for the push message banner.
When an expiry is set, the message will have an TTL in seconds. After the expiry, in seconds, has expired, the message will automatically be hidden.
| Function Name | Available Attributes |
|---|---|
__construct |
$token |
token |
string $token |
title |
?string $title |
topic |
?string $topicUuid |
avatar |
?string $url, ?string $body |
This is a basic example of creating a topic
$response = JustPushTopic::token('REPLACE_WITH_USER_TOKEN')
->title('New Topic')
->create();
echo json_encode($response->result(), JSON_PRETTY_PRINT); //Result
echo json_encode($response->responseHeaders(), JSON_PRETTY_PRINT); //Response HeadersThis is a basic example of updating a topic
$response = JustPushTopic::token('REPLACE_WITH_USER_TOKEN')
->topic('REPLACE_WITH_TOPIC_UUID')
->title('New Topic Title')
->update();
echo json_encode($response->result(), JSON_PRETTY_PRINT); //Result
echo json_encode($response->responseHeaders(), JSON_PRETTY_PRINT); //Response HeadersThis is a basic example of creating a topic
$response = JustPushTopic::token('REPLACE_WITH_USER_TOKEN')
->topic('REPLACE_WITH_TOPIC_UUID')
->get();
echo json_encode($response->result(), JSON_PRETTY_PRINT); //Result
echo json_encode($response->responseHeaders(), JSON_PRETTY_PRINT); //Response Headers| Key | Value | Description |
|---|---|---|
X-Limit-App-Limit |
["10000"] |
The amount of messages that you can send based on your active subscription |
X-Limit-App-Remaining |
["9895"] |
The amount of messages you have left for the current period in your subscription |
X-Limit-App-Limit |
["234512"] |
The seconds till the monthly reset will be done. |
The package comes with an OpenAPI spec. Which can be found in the docs folder. Click Here
- 1.0.17 - Added Button Groups
- 1.0.15 - Added retry mechanism for
acknowledgements