1. Go to this page and download the library: Download kodjunkie/onesignal-php-sdk library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
kodjunkie / onesignal-php-sdk example snippets
use Kodjunkie\OnesignalPhpSdk\OneSignal;
use Kodjunkie\OnesignalPhpSdk\Exceptions\OneSignalException;
$config = [
// Onesignal API Key
'api_key' => '',
// Onesignal Auth Key
'auth_key' => '',
// Onesignal App ID (optional)
// this is beneficial if you're working with a single OneSignal app
// so, you could pass "null" to methods / functions that
$app->register(Kodjunkie\OnesignalPhpSdk\OneSignalServiceProvider::class);
// Register the facade (optional)
// To use, must uncomment $app->withFacades()
if (!class_exists('OneSignal')) {
class_alias(Kodjunkie\OnesignalPhpSdk\Facade::class, 'OneSignal');
}
use Kodjunkie\OnesignalPhpSdk\Exceptions\OneSignalException;
try {
// Initialize the SDK
// Resolve from the IoC container
$oneSignal = app()->make('onesignal');
// Using the API
// Get all devices
$response = $oneSignal->device()->getAll($appId, $limit, $offset);
// Using the facade, the code above will look like this
// with "app_id" provided in the config
$response = OneSignal::device()->getAll(null, $limit, $offset);
dd($response);
} catch (OneSignalException $exception) {
dd($exception->getMessage());
}
bash
composer
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.