<?php

class kavehsms{

    public function __construct(){

    }

    public static function smsir($api, $mobile, $bodyId, $code){

        $curl = curl_init();
        curl_setopt_array($curl, array(
        CURLOPT_URL => 'https://api.sms.ir/v1/send/verify',
        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_POSTFIELDS =>'{
            "mobile": "'.$mobile.'",
            "templateId": '.$bodyId.',
            "parameters": [
                {
                "name": "CODE",
                "value": "'.$code.'"
                }
            ]
        }',
        CURLOPT_HTTPHEADER => array(
            'Content-Type: application/json',
            'Accept: text/plain',
            'x-api-key: '. $api
        ),
        ));
        curl_exec($curl);
        curl_close($curl);

    }

    public static function ippanel($username, $password, $mobile, $fromnum, $bodyId, $code){
        
        $client     = new SoapClient("http://188.0.240.110/class/sms/wsdlservice/server.php?wsdl");
        $input_data = array(
        "verification-code" => $code,
        );
        $client->sendPatternSms($fromnum, $mobile, $username, $password, $bodyId, $input_data);

    }

    public static function melipayamak($username, $password, $mobile, $bodyId, $code){
        
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL,"http://rest.payamak-panel.com/api/SendSMS/BaseServiceNumber");
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_POSTFIELDS, 'username='.$username.'&password='.$password.'&to='.$mobile.'&bodyId='.$bodyId.'&text='.$code);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        $server_output = curl_exec($ch);
        curl_close ($ch);

    }

    public static function raygansms($username, $password, $mobile, $message, $code){

        $Url = 'http://smspanel.Trez.ir/SendMessageWithCode.ashx';
        $args = array(
            'body' => array(
            'Username' => $username,
            'Password' => $password,
            'Mobile' => $mobile,
            'Message' => $message . $code,
            )
        );
        $response = wp_remote_get($Url, $args);
        if (is_wp_error($response)) {
        } else {
        $server_output = wp_remote_retrieve_body($response);
        }
        
    }


    public static function webone($username, $password, $from, $to, $message, $code){

        $Url = 'https://webone-sms.ir/SMSInOutBox/SendSms';
        $args = array(
            'body' => array(
            'username' => $username,
            'password' => $password,
            'from' => $from,
            'to' => $to,
            'text' => $message .' '. $code,
            )
        );
        $response = wp_remote_get($Url, $args);
        if (is_wp_error($response)) {
        } else {
        $server_output = wp_remote_retrieve_body($response);
        }
        
    }


    public static function kavehnegar($api, $mobile, $bodyId, $code){
        
        $url = "https://api.kavenegar.com/v1/$api/verify/lookup.json?receptor=$mobile&token=$code&template=$bodyId";
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        $response = curl_exec($ch);
        curl_close($ch);

    }

}