justpush / justpush-php-sdk
SDK To send push messages through PHP
Requires
- php: ^8.0
- ext-json: *
- guzzlehttp/guzzle: ^7.2
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.57
- phpunit/phpunit: ^11.1
README
JustPush - PHP SDK
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.
Features
- 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.
Download the App in the App Stores
Installation
Install the SDK via Composer:
composer require justpush/justpush-php-sdk
Basic Push Message
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
JustPush Message
Defining the topic
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
Sending multiple images
When a message contains multiple images, the first image will be used for the push message banner.
Setting an Expiry
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.
JustPush Topics
POST / Create A Topic
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 Headers
PUT / Update A Topic
This 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 Headers
GET / Get a topic
This 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
Response Headers
OpenApi Spec
The package comes with an OpenAPI spec. Which can be found in the docs
folder. Click Here
Changelog
- 1.0.15 - Added retry mechanism for
acknowledgements