• You MUST read the Babiato Rules before making your first post otherwise you may get permanent warning points or a permanent Ban.

    Our resources on Babiato Forum are CLEAN and SAFE. So you can use them for development and testing purposes. If your are on Windows and have an antivirus that alerts you about a possible infection: Know it's a false positive because all scripts are double checked by our experts. We advise you to add Babiato to trusted sites/sources or disable your antivirus momentarily while downloading a resource. "Enjoy your presence on Babiato"

Custom SMS & Email Notifications for Perfex CRM

Custom SMS & Email Notifications for Perfex CRM v.2.3.2

No permission to download
how we can add custom sms gateway here help please or any other module to add your own smsgateway ?
Need some coding knowledge i have added my own whatsapp gateway by replacing msg91 core files and its working perfectly from last 1+ year.
 
Can you share us your tips :) ?
Replace this code under application/libraries/sms > sms_msg91.php
with my link you can replace your sms provider link and country code but make sure your provider api structure support this type of variables in api

Code:
<?php

defined('BASEPATH') or exit('No direct script access allowed');

class Sms_msg91 extends App_sms
{
    private $auth_key;

    private $sender_id;

    private $apiRequestUrl = 'http://api.msg91.com/api/v2/sendsms';

    private $worldRequestUrl = 'http://msg.dsuinfotech.com/api/v2/sendhttp.php?';
    private $worldRequestUrlDSU = 'https://wa.apikaro.in/send';

    public function __construct()
    {
        parent::__construct();

        $this->sender_id = $this->get_option('msg91', 'sender_id');
        $this->auth_key  = $this->get_option('msg91', 'auth_key');
        $this->api_type  = $this->get_option('msg91', 'api_type');

        $this->add_gateway('msg91', [
                'info'    => "<p>Whatsapp API integration</p><hr class='hr-10'>",
                'name'    => 'DSU SMS',
                'options' => [
                    [
                        'name'  => 'sender_id',
                        'label' => 'Sender ID',
                        'info'  => '<p><a href="https://wa.apikaro.in" target="_blank">https://wa.apikaro.in</a></p>',
                    ],
                    [
                        'name'          => 'api_type',
                        'field_type'    => 'radio',
                        'default_value' => 'api',
                        'label'         => 'Api Type',
                        'options'       => [
                            ['label' => 'World', 'value' => 'world'],
                            ['label' => 'Api', 'value' => 'api'],
                        ],
                    ],
                    [
                        'name'  => 'auth_key',
                        'label' => 'Auth Key',
                    ],
                ],
            ]);
    }

    /**
     * Send sms
     *
     * @param  string $number
     * @param  string $message
     *
     * @return boolean
     */
    public function send($number, $message)
    {
        if ($this->api_type == 'world') {
            return $this->sendViaWorldRoute($number, $message);
        }

        return $this->sendViaApiRoute($number, $message);
    }

    /**
     * Send SMS via World Route
     *
     * @param  string $number
     * @param  string $message
     *
     * @return boolean
     */
    public function sendViaWorldRoute($number, $message)
    {
        try {
            $queryString = array_merge($this->getCommonQueryString(), [
                'mobiles'  => $number,
                'message'  => $message,
                'authkey'  => $this->auth_key,
                'response' => 'json',
            ]);
            
            $queryStringDSU = [
                'sender'  => $this->sender_id,
                'receiver'  => '91'.$number,
                'msgtext'  => $message,
                 'appurl'    => 'https://wa.apikaro.in',
                'token'  => $this->auth_key
            ];
            
            // $response = $this->client->request(
            //     'GET',
            //     $this->worldRequestUrl . '?' . http_build_query($queryString),
            //     $this->getCommonGuzzleOptions()
            // );
            
            $response = $this->client->request(
                'GET',
                $this->worldRequestUrlDSU . '?' . http_build_query($queryStringDSU),
                $this->getCommonGuzzleOptions()
            );
            
            $result = json_decode($response->getBody());

            if ($result->type == 'success') {
                $this->logSuccess($number, $message);

                return true;
            }

            $this->set_error($result->message);
        } catch (\Exception $e) {
            $response = json_decode($e->getResponse()->getBody()->getContents(), true);

            $this->set_error($response['message']);
        }

        return false;
    }

    /**
     * Send SMS via the regular API route
     *
     * @param  string $number
     * @param  string $message
     *
     * @return boolean
     */
    public function sendViaApiRoute($number, $message)
    {
        try {
            $response = $this->client->request(
                'POST',
                $this->apiRequestUrl,
                array_merge($this->getCommonGuzzleOptions(), [
                    'body' => json_encode(array_merge($this->getCommonQueryString(), [
                        'sms' => [
                            ['message' => urlencode($message), 'to' => [$number]],
                        ],
                    ])),
                    'headers' => [
                        'authkey' => $this->auth_key,
                    ],
                ])
            );

            $result = json_decode($response->getBody());

            if ($result->type == 'success') {
                $this->logSuccess($number, $message);

                return true;
            }

            $this->set_error($result->message);
        } catch (\Exception $e) {
            $response = json_decode($e->getResponse()->getBody()->getContents(), true);

            $this->set_error($response['message']);
        }

        return false;
    }

    /**
     * Get the sender name
     *
     * @return string
     */
    protected function getSender()
    {
        return empty($this->sender_id) ? get_option('companyname') : $this->sender_id;
    }

    /**
     * Get the API common query string options
     *
     * @return array
     */
    protected function getCommonQueryString()
    {
        return hooks()->apply_filters('msg91_common_options', [
                'route'   => 1,
                'country' => 0,
                'unicode' => 1,
                'sender'  => $this->getSender(),
            ]);
    }

    /**
     * Get the API common query string options
     *
     * @return array
     */
    protected function getCommonGuzzleOptions()
    {
        return [
            'allow_redirects' => [
                'max' => 10,
            ],
            'version'        => CURL_HTTP_VERSION_1_1,
            'decode_content' => [CURLOPT_ENCODING => ''],
            ];
    }
}
 
  • Love
Reactions: planet and NoOoB
@lineset1819 can you test this fix ?

Working fine for me
 

Attachments

  • custom-sms-email-notifications-for-perfex-crm-v2.3.2_nulledfixed.zip
    557.5 KB · Views: 133
  • Like
Reactions: maxpayneinfo

Add-on SMS Manager Module for Perfex CRM​

anyone can help me to search this module discussion on babiato i am not able to find. thank you
 
  • Like
Reactions: lineset1819
AdBlock Detected

We get it, advertisements are annoying!

However in order to keep our huge array of resources free of charge we need to generate income from ads so to use the site you will need to turn off your adblocker.

If you'd like to have an ad free experience you can become a Babiato Lover by donating as little as $5 per month. Click on the Donate menu tab for more info.

I've Disabled AdBlock