PHP code example of mobile-backend / php-sdk

1. Go to this page and download the library: Download mobile-backend/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/ */

    

mobile-backend / php-sdk example snippets


$config = [
    "client_key" => "XXXXXXXXXX",
    "application_key" => "XXXXXXXXXX",
    "domain" => "mb.api.cloud.nifty.com",
    "version" => "2013-09-01",
];

$mobileBackend = new \MobileBackend\PhpSdk\MobileBackend($config);
$json = $mobileBackend
    ->setMethod("GET")
    ->addQuery("target", [$os])
    ->setEndPoint("push")
    ->execute();

// message
$message = "A Happy New Year!!";

// send time
$dateTime = new \DateTime("2016-01-01 00:00:00");
$dateTime->setTimeZone(new \DateTimeZone("UTC"));
$deliveryTime = $dateTime->format("Y-m-d\TH:i:s.\0\0\0\Z");

$mobileBackend = new \MobileBackend\PhpSdk\MobileBackend($config);
$mobileBackend
    ->setMethod("POST")
    ->addQuery("message", $message)
    ->addQuery("deliveryTime", [
        "__type" => "Date",
        "iso" => $deliveryTime
    ])
    ->setEndPoint("push")
    ->execute();

// message
$message = "Edit Message";

// objectId
$objectId = "Edit Push Message ObjectId";

$mobileBackend = new \MobileBackend\PhpSdk\MobileBackend($config);
$mobileBackend
    ->setMethod("PUT")
    ->addQuery("message", $message)
    ->setEndPoint("push/". $objectId)
    ->execute();

$mobileBackend = new \MobileBackend\PhpSdk\MobileBackend($config);
$mobileBackend
    ->setMethod("DELETE")
    ->setEndPoint("push/" . $objectId)
    ->execute();
javascript
{
    "ackend/php-sdk": "*"
    }
}