0

I need to send order confirmation SMS message to my users via my SMS gateway API in PrestaShop. Is that possible?

I am using the ValueFirst SMS gateway.

Here is my code:

 <?php
    $username="username";
    $password="password";
    $to="mobilenumber";
    $sender="senderid";
    $message="message";
    if($username!='' && $password!='' && $to!='' && $sender!='' && $message!='')
    {
     class sendSms
    {
    var $serverURL = 'http://api.myvaluefirst.com/psms/servlet/psms.Eservice2';
     var $gsmSender = 'MYGSMID';
    function GetSenderID()
    {
        return $this->cdmaNumber;
    }
    function get_address($user_id,$to)
    {
        $address_info = sprintf('<ADDRESS FROM="%s" TO="%s" SEQ="%s" />',$user_id,$to,1);
        return $address_info;
    }
    function postdata($url,$data)
    {
        $objURL = curl_init($url);
        curl_setopt($objURL, CURLOPT_RETURNTRANSFER, 1); 
        curl_setopt($objURL,CURLOPT_POST,1);
        curl_setopt($objURL, CURLOPT_POSTFIELDS,$data);
        $retval = trim(curl_exec($objURL));
        curl_close($objURL);
        return $retval;
    }
    function sendSmsToUser($prefix='',$contents='', $toAddr='',$sms_user_name='',$sms_password='',$sms_user_id='' ) 
    {
    $xmlstr ='<!DOCTYPE MESSAGE SYSTEM "http://127.0.0.1/psms/dtd/message.dtd"><MESSAGE><USER USERNAME="%s" PASSWORD="%s"/><SMS  UDH=" 0 " CODING=" 1 " TEXT="%s" PROPERTY=" 0 " ID=" 2 ">%s</SMS></MESSAGE>'; 
            $contents = stripslashes($prefix.$contents);
            $contents = htmlentities($contents,ENT_COMPAT);         
            $username = stripslashes($sms_user_name);
            $username = htmlentities($username,ENT_COMPAT);         
            $password = stripslashes($sms_password);
            $password = htmlentities($password,ENT_COMPAT);         
            $user_id = stripslashes($sms_user_id);
            $user_id = htmlentities($user_id,ENT_COMPAT);           
            $xmldata = sprintf($xmlstr,$username,$password,$contents,$this->get_address($user_id,$toAddr));
            $data='data='. urlencode($xmldata);
            $action='action=send';
            $str_response = $this->postdata($this->serverURL,$action.'&'.$data);    
            $str_request = $this->serverURL.'?'.$action.'&'.$data;
    }
    }
    $mclass = new sendSms();
    $mclass->sendSmsToUser("Dear Guest,",$message,$to,$username,$password,$sender);
    }
    ?>

This is my ValueFirst API script. I want to use this script into PrestaShop. How can I do that?

ChrisGPT was on strike
  • 127,765
  • 105
  • 273
  • 257
Lingam Diaz
  • 31
  • 12

1 Answers1

0

I think this is kinda duplicate with this one : How to integrate msg91 php api with Prestasms or Prestashop?

For instance, create a module at https://validator.prestashop.com/ then add Hooks (function triggered at a certain time automaticly, like on order update) with it.

Matt Loye
  • 1,301
  • 2
  • 11
  • 14