All Projects → norkunas → Onesignal Php Api

norkunas / Onesignal Php Api

Licence: mit
OneSignal API for PHP

Labels

Projects that are alternatives of or similar to Onesignal Php Api

OneSignal-Java-SDK
OneSignal SDK
Stars: ✭ 28 (-86.67%)
Mutual labels:  onesignal
Laravel Onesignal
OneSignal Push Notifications for Laravel
Stars: ✭ 369 (+75.71%)
Mutual labels:  onesignal
Onesignal Ane
OneSignal extension for Adobe AIR (iOS & Android)
Stars: ✭ 39 (-81.43%)
Mutual labels:  onesignal
react-native-notifee
Moved to https://github.com/invertase/notifee
Stars: ✭ 477 (+127.14%)
Mutual labels:  onesignal
React Native Firebase Starter
The ultimate React Native starter using Firebase, Mobx, CodePush, OneSignal made with ♥
Stars: ✭ 289 (+37.62%)
Mutual labels:  onesignal
React Native Notifee
⚛️ A feature rich notifications library for React Native Android & iOS, built by @invertase, the authors of @react-native-firebase.
Stars: ✭ 381 (+81.43%)
Mutual labels:  onesignal
OneSignal-Ionic-Sample
No description or website provided.
Stars: ✭ 85 (-59.52%)
Mutual labels:  onesignal
Onesignal Ionic Example
Stars: ✭ 89 (-57.62%)
Mutual labels:  onesignal
Onesignal Website Sdk
OneSignal is a push notification service for web and mobile apps. This SDK makes it easy to integrate your website with OneSignal Push Notifications. https://onesignal.com
Stars: ✭ 338 (+60.95%)
Mutual labels:  onesignal
Onesignal Python
Python client for OneSignal push notification service
Stars: ✭ 33 (-84.29%)
Mutual labels:  onesignal
OneSignal-WordPress-Plugin
OneSignal is a free push notification service for web and mobile apps. This plugin makes it easy to integrate your website with OneSignal Push Notifications. https://onesignal.com
Stars: ✭ 71 (-66.19%)
Mutual labels:  onesignal
Social-Media-Monitor
Automatically monitor and log fan counters from social media(Facebook Pages, Twitter, Instagram, YouTube, Google+, OneSignal, Alexa) using APIs to Google Spreadsheet. Very useful for website admins and social media managers.
Stars: ✭ 36 (-82.86%)
Mutual labels:  onesignal
Onesignal Android Sdk
OneSignal is a free push notification service for mobile apps. This plugin makes it easy to integrate your native Android or Amazon app with OneSignal. https://onesignal.com
Stars: ✭ 503 (+139.52%)
Mutual labels:  onesignal
OneSignal-Codeigniter-Push-Notification
OneSignal is a free push notification service for web and mobile apps. This Codeigniter example makes it easy to integrate your website with OneSignal Push Notifications. https://onesignal.com/ DEMO - http://ci3onesignal.codefort.ru/
Stars: ✭ 27 (-87.14%)
Mutual labels:  onesignal
Onesignal Gradle Plugin
Use with OneSignal-Android-SDK to help integrate it into your Android Studio or Gradle project. https://onesignal.com
Stars: ✭ 49 (-76.67%)
Mutual labels:  onesignal
node-onesignal
Node.js wrapper for the One Signal API
Stars: ✭ 33 (-84.29%)
Mutual labels:  onesignal
Onesignal Ios Sdk
OneSignal is a free push notification service for mobile apps. This plugin makes it easy to integrate your native iOS app with OneSignal. https://onesignal.com
Stars: ✭ 370 (+76.19%)
Mutual labels:  onesignal
Black.box
Plug-and-Play VPN router and unblocker
Stars: ✭ 89 (-57.62%)
Mutual labels:  onesignal
React Native Onesignal
React Native Library for OneSignal Push Notifications Service
Stars: ✭ 1,270 (+504.76%)
Mutual labels:  onesignal
Beaverandfairies
Stars: ✭ 14 (-93.33%)
Mutual labels:  onesignal

OneSignal API for PHP

Latest Stable Version Latest Unstable Version Scrutinizer Code Quality Total Downloads CI Status License

Install

Note: All examples are for v2, if you are using PHP <7.3 please read v1 documentation.

This packages requires a PSR-18 HTTP client and PSR-17 HTTP factories to work. You can choose any from psr/http-client-implementation and psr/http-factory-implementation

Example with Symfony HttpClient and nyholm/psr7 http factories, install it with Composer:

composer require symfony/http-client nyholm/psr7 norkunas/onesignal-php-api

And now configure the OneSignal api client:

<?php

declare(strict_types=1);

use OneSignal\Config;
use OneSignal\OneSignal;
use Symfony\Component\HttpClient\Psr18Client;
use Nyholm\Psr7\Factory\Psr17Factory;

require __DIR__ . '/vendor/autoload.php';

$config = new Config('your_application_id', 'your_application_auth_key', 'your_auth_key');
$httpClient = new Psr18Client();
$requestFactory = $streamFactory = new Psr17Factory();

$oneSignal = new OneSignal($config, $httpClient, $requestFactory, $streamFactory);

How to use this library

Applications API

View the details of all of your current OneSignal applications (official documentation):

$myApps = $oneSignal->apps()->getAll();

View the details of a single OneSignal application (official documentation):

$myApp = $oneSignal->apps()->getOne('application_id');

Create a new OneSignal app (official documentation):

$newApp = $oneSignal->apps()->add([
    'name' => 'app name',
    'gcm_key' => 'key'
]);

Update the name or configuration settings of OneSignal application (official documentation):

$oneSignal->apps()->update('application_id', [
    'name' => 'new app name'
]);

Create Segments (official documentation):

$oneSignal->apps()->createSegment('application_id', [
    'name' => 'Segment Name',
    'filters' => [
        ['field' => 'session_count', 'relation' => '>', 'value' => 1],
        ['operator' => 'AND'],
        ['field' => 'tag', 'relation' => '!=', 'key' => 'tag_key', 'value' => '1'],
        ['operator' => 'OR'],
        ['field' => 'last_session', 'relation' => '<', 'value' => '30,'],
    ],
]);

Delete Segments (official documentation):

$oneSignal->apps()->deleteSegment('application_id', 'segment_id');

Devices API

View the details of multiple devices in one of your OneSignal apps (official documentation):

$devices = $oneSignal->devices()->getAll();

View the details of an existing device in your configured OneSignal application (official documentation):

$device = $oneSignal->devices()->getOne('device_id');

Register a new device to your configured OneSignal application (official documentation):

use OneSignal\Api\Devices;

$newDevice = $oneSignal->devices()->add([
    'device_type' => Devices::ANDROID,
    'identifier' => 'abcdefghijklmn',
]);

Update an existing device in your configured OneSignal application (official documentation):

$oneSignal->devices()->update('device_id', [
    'session_count' => 2,
]);

Notifications API

View the details of multiple notifications (official documentation):

$notifications = $oneSignal->notifications()->getAll();

Get the details of a single notification (official documentation):

$notification = $oneSignal->notifications()->getOne('notification_id');

Create and send notifications or emails to a segment or individual users. You may target users in one of three ways using this method: by Segment, by Filter, or by Device (at least one targeting parameter must be specified) (official documentation):

$oneSignal->notifications()->add([
    'contents' => [
        'en' => 'Notification message'
    ],
    'included_segments' => ['All'],
    'data' => ['foo' => 'bar'],
    'isChrome' => true,
    'send_after' => new \DateTime('1 hour'),
    'filters' => [
        [
            'field' => 'tag',
            'key' => 'is_vip',
            'relation' => '!=',
            'value' => 'true',
        ],
        [
            'operator' => 'OR',
        ],
        [
            'field' => 'tag',
            'key' => 'is_admin',
            'relation' => '=',
            'value' => 'true',
        ],
    ],
    // ..other options
]);

Mark notification as opened (official documentation):

$oneSignal->notifications()->open('notification_id');

Stop a scheduled or currently outgoing notification (official documentation):

$oneSignal->notifications()->cancel('notification_id');

Notification History (official documentation):

$oneSignal->notifications()->history('notification_id', [
    'events' => 'clicked', // or 'sent'
    'email' => '[email protected]',
]);

Questions?

If you have any questions please open an issue.

License

This library is released under the MIT License. See the bundled LICENSE file for details.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].