MigaPushAPI

On July 8, 2022, Posted by , In English, With Comments Off on MigaPushAPI

Orientation

This module is very simple, and allows external applications to:

  • send individual push notifications via customer email
  • fetch user list

Settings

You can access the Settings tab from app builder frontend. From Vertical menu on the left, click on Module section and so “Miga Push Api”.

You have to set only the maximum per minute sends a push to the customer. Also, user can regenerate token if any need.

Note:

  • API URL For Send Individual Push use with post request and also five fields are required {`app_id`, `token`, `message`, `subject`, ’email’} but “email” is the most important field
  • API URL Get Users List use with post request and also two fields are required {`app_id`, `token`}

User List

Description

Fetch all the users available for sending Push notifications.

$endpoint = "https://www.domain.com/migapushapi/public_apiusers/init"

Request

ParamType
app_idint
tokenstring

Response

{
    “error”: null,
    “data”: [
        {
            “email”: “user.com”,
            “firstname”: “user”,
            “lastname”: “x”
        },
        {
            “email”: “user2.com”,
            “firstname”: “user2”,
            “lastname”: “x”
        }
    ]
}

 

Example

 

Send Individual Push

Description

Sends an individual push notification via user email.

$endpoint = "http://www.domain.com/migapushapi/public_api/init"

Request

ParamTypeDetails
subject *stringPush title
message *stringPush message
app_id *int
token *string
email *string
devicesstringallandroidios
open_urlintIf set to 1 url will be opened in app
urlstringAlong with open_url set to 1, the url to open
coverstringbase64 encoded image to display as a cover, must be png or jpg.

For Example: data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEASABIAAD………

Cover Image BASE64 Conversion Steps.

  • Go to BASE64 Conversion link
  • Choose a cover image (jpg, png)
  • Select output type format (Data URI — data:content/type;base64)
  • Click on encode image button.

Example of PHP implementation

For Get User List

<?php

$url = ‘https://domain.com/migapushapi/public_apiusers/init’;
    $data = array(
        “app_id” => “11”,
        “token” => “c89222798a03a0c7efdb851ec38…….”,
    );
    $curlHandler = curl_init();
    curl_setopt_array($curlHandler, [
        CURLOPT_URL => $url,
        CURLOPT_RETURNTRANSFER => true,
        /**
        * Specify POST method
        */
        CURLOPT_POST => true,
        /**
        * Specify request content
        */
        CURLOPT_POSTFIELDS => $data,
    ]);
    $response = curl_exec($curlHandler);
    curl_close($curlHandler);
    echo($response);

?>

 

For Send Push Notification

<?php

    $url = “https://domain.com/migapushapi/public_api/init”;
    $data = array(
        “app_id” => “11”,
        “token” => “c892227…….”,
        “message” => “Message……”,
        “subject” => “Subject……..”,
        “email” => “email@gmail.com”,
        “devices” => “android”,
        “open_url”=>1,
        “url” => “https://domain.com/api/push/”,
        “cover”=>”data:image/png;base64,iVBORw0KGgoAAAANSUhE……………..”
    );
    $curlHandler = curl_init();
    curl_setopt_array($curlHandler, [
    CURLOPT_URL => $url,
    CURLOPT_RETURNTRANSFER => true,
    /**
    * Specify POST method
    */
    CURLOPT_POST => true,
    /**
    * Specify request content
    */
    CURLOPT_POSTFIELDS => $data,
    ]);
    $response = curl_exec($curlHandler);
    curl_close($curlHandler);
    echo($response);

?>

Example of Javascript implementation

For Get User List

    <script>
        $.ajax({
            url: “https://domain.com/migapushapi/public_apiusers/init”,
            type: “post”,
            data: {
                “app_id”: “11”,
                “token”: “c89222798a03a……”
            } ,
            success: function (response) {
                console.log(response);
            },
            error: function(jqXHR, textStatus, errorThrown) {
            console.log(textStatus, errorThrown);
            }
        });
    </script>
For Send Push Notification
<script>
    $.ajax({
        url: “https://domain.com/migapushapi/public_apiusers/init”,
        type: “post”,
        data: {
            “app_id” : “11”,
            “token” : “c892227…….”,
            “message” : “Message……”,
            “subject” : “Subject……..”,
            “email” : “email@gmail.com”,
            “devices” : “android”,
            “open_url” :1,
            “url” : “https://domain.com/api/push/”,
            “cover”:”data:image/png;base64,iVBORw0KGgoAAAANSUhE……………..”
        },
        success: function (response) {
            console.log(response);
        },
        error: function(jqXHR, textStatus, errorThrown) {
            console.log(textStatus, errorThrown);
        }
    });
</script>

Success Response

{
    “success”: true,
    “response”: 1
}

 

All Response

ResponseDetails
1Successful
0Wrong/Missing Token
2App ID is missing
3Email is missing”
4Email User hasn’t a push token
5Message field is empty
6Subject is missing
7Url is missing (if field OpenUrl is 1 value and Url is empty)
8Wrong Cover Image base64 encoded image to display as a cover, must be png or jpg
9Invalid Request
10Invalid Parameter(s) Found.
11Already user send max push plz wait one minute
12Email does not exists
13Cover image size must be smaller than 1MB
14Cover image must be jpg, png

 

Example

LINK: https://support.migastone.com/en/hrf_faq/migapushapi/