Subscribe to the newsletter endpoint

Updated on Jan 11, 2023

Introduction

By visiting this endpoint, users can provide their phone number and subscribe to receive SMS messages from the website administrator. Once user submitted their phone number it should be verified by a code that is sent to the phone number provided by the plugin then they will be added to the subscriber’s list and will receive the SMS newsletter.

POST /wp-json/wpsms/v1/newsletter?name=YourName&mobile=YourMobile

Request

<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'http://site.com/wp-json/wpsms/v1/newsletter?name=Kimberly&mobile=0911111113',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_HTTPHEADER => array(
    'Authorization: Basic ***',
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

Response

{
    "message": "You shall join to the SMS newsletter, Activation code has been sent to your mobile.",
    "error": []
}