Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- define("APIURL", 'https://mastamobile.com/autosms/sendAPI.php?');
- class MastaMobile {
- var $array;
- function __construct() {
- $this->array = array();
- return $this;
- }
- public function setDeviceID($deviceID) {
- $this->array['deviceId'] = $deviceID;
- return $this;
- }
- public function setToPhone($toPhone) {
- $this->array['toPhone'] = $toPhone;
- return $this;
- }
- public function setMessage($message) {
- $this->array['message'] = $message;
- return $this;
- }
- public function process($deviceID = '', $toPhone = '', $message = '') {
- if (!empty($deviceID) && !empty($toPhone) && !empty($message)) {
- $this->array['deviceId'] = $deviceID;
- $this->array['toPhone'] = $toPhone;
- $this->array['message'] = $message;
- }
- // Only compatible with WordPress. Else, return false
- if (function_exists('wp_safe_remote_post')) {
- // Send this payload to MastaMobile for processing
- $response = wp_safe_remote_post(APIURL, $this->prepareMM($this->array));
- $status = json_decode(wp_remote_retrieve_body($response), true);
- if ($status['status'] == 'success') {
- return true;
- } else {
- return false;
- }
- } else {
- return false;
- }
- }
- private function prepareMM($data) {
- $args = array();
- $args['method'] = 'POST';
- $args['body'] = http_build_query($data);
- return $args;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement