コード例 #1
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $jobs = Job::whereNull('texted_at')->where('job_status_id', '=', JobStatus::$OPEN)->where('start_date', '>=', date("Y-m-d"))->orderBy("start_date")->get();
     $catJobs = array();
     $users = array();
     $userJobs = array();
     $userCategories = array();
     $user_ids = array();
     $jobs->load("jobCategory", "user");
     // echo '<pre>';
     //print_r($jobs);
     //echo '</pre>';
     foreach ($jobs as $job) {
         if (trim($job->latitude) != "" && trim($job->longitude) != "") {
             $userAddresses = Address::select("addresses.*", "student_profile.preferred_job_radius", Address::distanceSelectStatement($job->latitude, $job->longitude, 'distance', 'addresses'))->join("student_profile", "addresses.user_id", "=", "student_profile.user_id")->get();
             foreach ($userAddresses as $address) {
                 if ($address->distance > 0 && $address->distance <= $address->preferred_job_radius) {
                     //echo "here".$address->distance;
                     if (!isset($userCategories[$address->user_id])) {
                         $userCategories[$address->user_id] = StudentJobPreference::where('user_id', '=', $address->user_id)->lists('job_category_id');
                     }
                     if (in_array($job->job_category_id, $userCategories[$address->user_id]) == 1) {
                         if (!isset($userJobs[$address->user_id])) {
                             $user_ids[] = $address->user_id;
                             $userJobs[$address->user_id] = array();
                             $users[$address->user_id] = $address->user;
                         }
                         $userJobs[$address->user_id][] = $job;
                     }
                 }
             }
         }
         //$job->notified_at=date('Y-m-d h:i:s');
         $job->texted_at = date('Y-m-d h:i:s');
         $job->save();
     }
     $c = 0;
     if (count($user_ids) > 0) {
         $notifications = UserNotification::whereIn('user_id', $user_ids)->where("notification_types_id", '=', NotificationType::$SMS)->get();
         foreach ($notifications as $notification) {
             $user = $users[$notification->user_id];
             //$this->info($user->id);
             $c++;
             $this->info($notification->notification_value);
             $message = View::make('sms.commands.job_notifications');
             if (trim($notification->notification_value) != "" && !is_null($notification->notification_value)) {
                 try {
                     Twilio::message($notification->notification_value, substr($message, 0, 160));
                 } catch (Exception $e) {
                     \Log::info('Error: ' . $e->getMessage());
                     $this->info('Error: ' . $e->getMessage());
                 }
             }
         }
     }
     \Log::info('Cron Notification Text: ' . $c);
     $this->info($c . 'text sent');
 }
コード例 #2
0
 public function sendVerification($mobile, $passcode)
 {
     try {
         Twilio::message("+91{$mobile}", "Enter {$passcode} on the sign up page to verify your account. This is one time message from Couture.");
         return true;
     } catch (Exception $exc) {
         //echo $exc->getTraceAsString();
         return false;
     }
 }
コード例 #3
0
 /**
  * Execute the console command.
  *
  * @return void
  */
 public function fire()
 {
     $this->line('Creating a call via Twilio to: ' . $this->argument('phone'));
     // Grab options
     $from = $this->option('from');
     $url = $this->option('url');
     // Set a default URL if we havent specified one since is mandatory.
     if (is_null($url)) {
         $url = 'http://demo.twilio.com/docs/voice.xml';
     }
     \Twilio::call($this->argument('phone'), $url, array(), $from);
 }
コード例 #4
0
 /**
  * Execute the console command.
  *
  * @return void
  */
 public function fire()
 {
     $this->line('Sending SMS via Twilio to: ' . $this->argument('phone'));
     // Grab the text option if specified
     $text = $this->option('text');
     // If we havent specified a message, setup a default one
     if (is_null($text)) {
         $text = "This is a test message sent from the artisan console";
     }
     $this->line($text);
     \Twilio::message($this->argument('phone'), $text);
 }
コード例 #5
0
ファイル: JobsController.php プロジェクト: aeastmead/blinxly
 private function NotifyFavorite($user, $job)
 {
     foreach ($user->userNotifications as $notification) {
         switch ($notification->notification_types_id) {
             case NotificationType::$SMS:
                 try {
                     $message = View::make("sms.job_applicant.private_awarded", compact('job'));
                     Twilio::message($notification->notification_value, substr($message, 0, 160));
                 } catch (Exception $e) {
                     //$notify->notes=print_r($e,true);
                     //\Log::info(print_r($e,true));
                 }
                 break;
             case NotificationType::$ALTERNATIVEEMAIL:
                 if (trim($notification->notification_value) != "") {
                     try {
                         Mail::send('emails.job_applicants.private_awardee', array('awardee' => $user, 'job' => $job), function ($message) use($notification, $user) {
                             $message->from('*****@*****.**', 'QuadJobs');
                             $message->to($notification->notification_value, $user->first_name . ' ' . $user->last_name);
                             $message->subject('Job Revoked');
                         });
                     } catch (Exception $e) {
                         //$notify->notes=print_r($e,true);
                         //\Log::info(print_r($e,true));
                     }
                 }
                 break;
             case NotificationType::$EDUEMAIL:
                 try {
                     Mail::send('emails.job_applicants.private_awardee', array('awardee' => $user, 'job' => $job), function ($message) use($student) {
                         $message->from('*****@*****.**', 'QuadJobs');
                         $message->to($student->email, $student->first_name . ' ' . $student->last_name);
                         $message->subject('Job Revoked');
                     });
                 } catch (Exception $e) {
                     //$notify->notes=print_r($e,true);
                     //\Log::info(print_r($e,true));
                 }
                 break;
         }
     }
 }
コード例 #6
0
 public function registerMultipleUsers()
 {
     $input = Input::all();
     //dd(Input::all());
     //$input = json_decode(Input::get('data'));
     //$input = json_decode($json);
     \Log::error($input);
     \Log::error($input['event']);
     $event_num = $input['event'];
     $names = $input['names'];
     //$event_num = $input->event;
     //$names = $input->names;
     //dd($event_num);
     for ($i = 0; $i < count($names); $i++) {
         \Log::error($names[$i]);
         $user = User::where('name', '=', $names[$i])->first();
         \Log::error($user);
         if (isset($user)) {
             $user->occasions()->attach($event_num);
             $user->save();
             $app_id = 'jVmr9Q4ItzKs2abze4T2mRvECJ8AxMwCKT5G8anC';
             $rest_key = 'hNv7GwawFKdvpyb6B6u8sLqlSQMW3YWWRQeKVll7';
             $master_key = 'wzwEOPsb5w45qWQQVJSCqTtL6yvD82Y90SiVDh4y';
             ParseClient::initialize($app_id, $rest_key, $master_key);
             $data = array("alert" => "You have been invited to an event! Press here to learn more.");
             $query = ParseInstallation::query();
             $query->equalTo("device_id", $user->id);
             ParsePush::send(array("where" => $query, "data" => $data));
             Twilio::message($user->phone, 'You have been invited to an event! Open up Calendr to learn more.');
             $data = array('temp');
             /*
             		Mail::send('emails.invite', $data, function($message) use ($user)
             		{
             			\Log::info($user->email);
             		    $message->to($user->email, 'Jane Doe')->subject('You have been invited to an event!');
             		});
             */
         }
     }
 }
コード例 #7
0
 function sendmessage($destination)
 {
     global $club, $messageData, $messageSubject, $event, $sms, $user, $recipientMobile, $recipientEmail;
     foreach ($destination as $recipient) {
         //send email notification of acceptance queue
         $data = array('club' => $club, 'messageOriginal' => $messageData, 'subject' => $messageSubject, 'team' => $event);
         Mail::later(3, 'emails.announcement.default', $data, function ($message) use($recipient, $club, $messageSubject) {
             $message->to($recipient['email'], $recipient['name'])->subject("{$messageSubject} | " . $club->name);
         });
         $recipientEmail[] = array('name' => $recipient['name'], 'email' => $recipient['email']);
         if (Input::get('sms')) {
             $recipientMobile[] = array('name' => $recipient['name'], 'mobile' => $recipient['mobile']);
             //queue sms
             Queue::push(function ($job) use($recipient, $sms) {
                 Twilio::message($recipient['mobile'], $sms);
                 $job->delete();
             });
         }
     }
 }
コード例 #8
0
ファイル: sms.php プロジェクト: runderwood/obfind
 public function post()
 {
     $twreq = Twilio_Request::factory();
     if (!$twreq->check_signature(OBFind::TWILIO_AUTH_TOKEN)) {
         header('HTTP/1.1 403 Forbidden');
         throw new Exception('Invalid signature.');
     }
     $parsedq = OBFind::parse_query($twreq->msg_body);
     $qflag = $parsedq->tflag;
     $qadd = $parsedq->address;
     $qtag = $parsedq->tag ? $parsedq->tag : null;
     $qnum = $twreq->from;
     $last = false;
     if ($qnum && ($last = OBFind_Track::find($qnum))) {
         $last = (object) $last;
     }
     switch ($qflag) {
         case 'at':
             $loc = OBFind::find_address($qadd);
             if ($loc) {
                 $loc = $loc['approx_loc'];
                 if ($last) {
                     OBFind_Track::update($qnum, $qflag, $qadd, $loc, $qtag);
                 } else {
                     OBFind_Track::create($qnum, $qflag, $qadd, $loc, $qtag);
                 }
                 Twilio::send_sms($qnum, "ok: you're at {$qadd}");
             } else {
                 if (!$result) {
                     Twilio::send_sms($qnum, 'sorry. couldn\'t find that address (at).');
                 }
             }
             break;
         case 'near':
             $result = $qtag ? OBFind::find_tagged($qtag, $qadd) : OBFind::find($qadd);
             if (!$result) {
                 if (!OBFind::find_address($qadd)) {
                     Twilio::send_sms($qnum, 'sorry. couldn\'t find that address.');
                 } else {
                     Twilio::send_sms($qnum, 'found nothing nearby. try another address or start something new.');
                 }
             } else {
                 Twilio::send_sms($qnum, 'result 1: ' . $result);
             }
             if ($last) {
                 OBFind_Track::update($qnum, $qflag, $qadd, $qtag);
             } else {
                 OBFind_Track::create($qnum, $qflag, $qadd, $qtag);
             }
             break;
         case '?':
             if ($last) {
                 $result = $last->tag ? OBFind::find_tagged($last->tag, $qadd) : OBFind::find($last->address, $qadd);
                 if (!$result) {
                     Twilio::send_sms($qnum, 'sorry. couldn\'t find that address.');
                 }
                 if (!$result) {
                     if (!OBFind::find_address($qadd)) {
                         Twilio::send_sms($qnum, 'sorry. couldn\'t find that address.');
                     } else {
                         Twilio::send_sms($qnum, 'nothing else nearby. try another address or start something new.');
                     }
                 } else {
                     Twilio::send_sms($qnum, 'result ' . $qadd . ': ' . $result);
                 }
             } else {
                 Twilio::send_sms($qnum, 'no query. text "near <your address>".');
             }
             break;
         default:
             TWilio::send_sms('invalid command. text "near <your address>" to get started.');
             break;
     }
 }
コード例 #9
0
ファイル: TwilioVerify.php プロジェクト: j42/laravel-twilio
 protected function sendCall($phone, array $token)
 {
     $responses = \Twilio::call(['to' => $phone, 'twiml' => Config::get('laravel-twilio::twiml') . '/twilio/verify/twiml?code=' . $token['token']]);
     // Update Model
     if ($responses[$phone]->status === 'queued') {
         $this->phone = Cookie::get('twilio::phone');
     }
     // Respond w/ 2 Minute TTL
     return $this->respond(['phone' => $phone, 'status' => isset($responses[$phone]) ? $responses[$phone]->status : null], 200)->withCookie($token['cookie']);
 }
コード例 #10
0
 public function ProcessSMS()
 {
     require_once "Twilio.php";
     $sms_sender_id = Yii::app()->functions->getOptionAdmin('sms_sender_id');
     $sms_account_id = Yii::app()->functions->getOptionAdmin('sms_account_id');
     $sms_token = Yii::app()->functions->getOptionAdmin('sms_token');
     $nexmo_sender_id = Yii::app()->functions->getOptionAdmin('nexmo_sender_id');
     $nexmo_key = Yii::app()->functions->getOptionAdmin('nexmo_key');
     $nexmo_secret = Yii::app()->functions->getOptionAdmin('nexmo_secret');
     $nexmo_use_curl = Yii::app()->functions->getOptionAdmin('nexmo_use_curl');
     $sms_provider = Yii::app()->functions->getOptionAdmin('sms_provider');
     $clickatel_user = Yii::app()->functions->getOptionAdmin('clickatel_user');
     $clickatel_password = Yii::app()->functions->getOptionAdmin('clickatel_password');
     $clickatel_api_id = Yii::app()->functions->getOptionAdmin('clickatel_api_id');
     $clickatel_use_curl = Yii::app()->functions->getOptionAdmin('clickatel_use_curl');
     $nexmo_use_unicode = Yii::app()->functions->getOptionAdmin('nexmo_use_unicode');
     $clickatel_use_unicode = Yii::app()->functions->getOptionAdmin('clickatel_use_unicode');
     $clickatel_sender = Yii::app()->functions->getOptionAdmin('clickatel_sender');
     $privatesms_username = Yii::app()->functions->getOptionAdmin('privatesms_username');
     $privatesms_password = Yii::app()->functions->getOptionAdmin('privatesms_password');
     $privatesms_sender = Yii::app()->functions->getOptionAdmin('privatesms_sender');
     /*dump($sms_sender_id);
     		dump($sms_account_id);
     		dump($sms_token);*/
     $db_ext = new DbExt();
     $stmt = "\n\t\tSELECT * FROM\n\t\t{{sms_broadcast_details}}\n\t\tWHERE\n\t\tstatus IN ('pending')\n\t\tORDER BY id ASC\n\t\tLIMIT 0,50\n\t\t";
     if ($res = $db_ext->rst($stmt)) {
         foreach ($res as $val) {
             dump($val);
             //$available_credit=Yii::app()->functions->getMerchantSMSCredit(Yii::app()->functions->getMerchantID());
             $available_credit = Yii::app()->functions->getMerchantSMSCredit($val['merchant_id']);
             dump($available_credit);
             if ($available_credit >= 1) {
                 //if ( !empty($sms_sender_id) && !empty($sms_account_id) && !empty($sms_token)){
                 $raw = '';
                 $msg = '';
                 if ($sms_provider == "nexmo") {
                     $Nexmo = new Nexmo();
                     $Nexmo->key = $nexmo_key;
                     $Nexmo->secret = $nexmo_secret;
                     $Nexmo->sender = $nexmo_sender_id;
                     $Nexmo->to = $val['contact_phone'];
                     $Nexmo->message = $val['sms_message'];
                     $Nexmo->is_curl = $nexmo_use_curl;
                     if ($nexmo_use_unicode == 1) {
                         $Nexmo->unicode = true;
                     }
                     try {
                         $raw = $resp = $Nexmo->sendSMS();
                         $msg = "process";
                     } catch (Exception $e) {
                         $msg = $e->getMessage();
                     }
                 } elseif ($sms_provider == "clickatell") {
                     $Clickatell = new Clickatell();
                     $Clickatell->user = $clickatel_user;
                     $Clickatell->password = $clickatel_password;
                     $Clickatell->api_id = $clickatel_api_id;
                     $Clickatell->is_curl = $clickatel_use_curl;
                     $Clickatell->to = $val['contact_phone'];
                     $Clickatell->message = $val['sms_message'];
                     if ($clickatel_use_unicode == 1) {
                         $Clickatell->unicode = true;
                     }
                     $Clickatell->sender = $clickatel_sender;
                     try {
                         $raw = $resp = $Clickatell->sendSMS();
                         $msg = "process";
                     } catch (Exception $e) {
                         $msg = $e->getMessage();
                     }
                 } elseif ($sms_provider == "private") {
                     $obj = new Sender("103.16.101.52", "80", $privatesms_username, $privatesms_password, $privatesms_sender, $val['sms_message'], $val['contact_phone'], "0", "1");
                     $resp = $obj->Submit();
                     if (preg_match("/1701/i", $resp)) {
                         $raw = $resp;
                         $msg = "process";
                     } else {
                         $errors['1702'] = "Invalid URL Error, This means that one of the parameters was not\n\t\t\tprovided or left blank";
                         $errors['1703'] = "Invalid value in username or password field";
                         $errors['1704'] = 'Invalid value in "type" field';
                         $errors['1705'] = "Invalid Message";
                         $errors['1706'] = "Invalid Destination";
                         $errors['1707'] = "Invalid Source (Sender)";
                         $errors['1708'] = 'Invalid value for "dlr" field';
                         $errors['1709'] = "User validation failed";
                         $errors['1710'] = "Internal Error";
                         $errors['1025'] = "Insufficient Credit";
                         $resp_temp = explode("|", $resp);
                         if (is_array($resp_temp) && count($resp_temp) >= 1) {
                             $code_error = $resp_temp[0];
                         } else {
                             $code_error = $resp;
                         }
                         $raw = $resp;
                         if (array_key_exists($code_error, $errors)) {
                             $msg = $errors[$code_error];
                         } else {
                             $msg = "Undefined response from api.";
                         }
                     }
                 } else {
                     $twilio = new Twilio();
                     $twilio->_debug = false;
                     $twilio->sid = $sms_account_id;
                     $twilio->auth = $sms_token;
                     $twilio->data['From'] = $sms_sender_id;
                     $twilio->data['To'] = $val['contact_phone'];
                     $twilio->data['Body'] = $val['sms_message'];
                     if ($resp = $twilio->sendSMS()) {
                         $raw = $twilio->getSuccessXML();
                         $msg = "process";
                     } else {
                         $msg = $twilio->getError();
                     }
                 }
                 //} else $msg=Yii::t("default","Admin SMS Settings Invalid");
             } else {
                 $msg = Yii::t("default", "No SMS Credit");
             }
             $params = array('status' => $msg, 'gateway_response' => $raw, 'date_executed' => date('c'), 'gateway' => $sms_provider);
             $db_ext->updateData("{{sms_broadcast_details}}", $params, 'id', $val['id']);
         }
     } else {
         echo "<p>No records to process</p>";
     }
 }
コード例 #11
0
ファイル: routes.php プロジェクト: wyrover/aeroeco
     });
     return 'Email Sent!';
 });
 Route::get('xlimport/{dir}/{file}', ['as' => 'xlimport', 'uses' => 'ExcelController@fromExcel']);
 Route::get('event', function () {
     logit('created a test event');
 });
 Route::get('tester', function () {
     return view('pages.tester');
 });
 Route::get('notifier', function () {
     notify(Auth::user()->id, '2', 'Angelina Jole just friended you.');
     return 'Notification Saved!';
 });
 Route::get('sms/{phone}', function ($phone) {
     Twilio::message($phone, 'Hi, I am Echo from the AeroEco software. I can now send but not receive text messages. Pretty cool, huh?');
     return 'Message sent';
 });
 Route::get('messenger', function () {
     tweet('2', 'Dude, why are you sending yourself a message? Are you some kind of freak? Oh, you are just testing.');
     return 'Message Saved!';
 });
 Route::get('systemic', function () {
     $user = Auth::user();
     Activity::log(['contentId' => null, 'contentType' => 'User', 'action' => 'LogIn', 'description' => 'Logged In', 'details' => 'Username: '******'updated' => (bool) $user->id]);
     return 'Activity logged';
 });
 Route::get('welcome_page', function () {
     flash()->overlay('Hello, World!', 'This is the message');
     return view('pages.welcome');
 });
コード例 #12
0
 public function message($number, $message)
 {
     return \Twilio::message($number, $message);
 }
コード例 #13
0
    public function storeSchedule()
    {
        $input['json'] = '{
						    "user": "******",
						    "event": "1",
						    "time_slots": [
						        {
						            "start": 1411239474,
						            "end": 1411539474,
						            "weighting": "5"
						        },
						        {
						            "start": 1411269474,
						            "end": 1411549474,
						            "weighting": "5"
						        }
						    ]
						}';
        $decoded = json_decode($input['json']);
        $user_id = $decoded->user;
        $occasion_id = $decoded->event;
        // Get the occasion tied to the user
        $occasion = User::find($user_id)->occasions->find($occasion_id);
        if ($occasion == null) {
            return null;
        }
        $time_slots = $decoded->time_slots;
        $insert = array();
        for ($i = 0; $i < count($time_slots); $i++) {
            $start = $time_slots[$i]->start;
            $ts_start = Carbon::createFromTimeStamp($start);
            $end = $time_slots[$i]->end;
            $ts_end = Carbon::createFromTimeStamp($end);
            $insert[] = array('start' => $ts_start->toDateTimeString(), 'end' => $ts_end->toDateTimeString(), 'weighting' => $time_slots[$i]->weighting, 'user_id' => $user_id, 'occasion_id' => $occasion_id);
        }
        //dd($insert);
        Timeslot::insert($insert);
        $occasion->pivot->complete = 1;
        $occasion->pivot->save();
        $num_incomplete_occasions = Occasion::find($occasion_id)->users()->wherePivot('complete', 0)->count();
        if ($num_incomplete_occasions != 0) {
            return $occasion;
        }
        // The events are done - push
        $occasion = Occasion::find($occasion_id);
        $host_start = new Carbon($occasion->start);
        $host_end = new Carbon($occasion->end);
        $diff = $host_start->diffInMinutes($host_end);
        $num_users = $occasion->users->count();
        $score = array();
        $score = array_fill(0, 10000, 0);
        //$score[0] = 'test';
        //$score = 0;
        $k = 0;
        $previous = new Carbon($occasion->start);
        // implement eager loading
        for ($i = 0; $i < $diff; $i += 15) {
            for ($j = 0; $j < $num_users; $j++) {
                $start = new Carbon($occasion->start);
                $start->addMinutes($i);
                $timeslot = Timeslot::where('user_id', '=', $j)->where('start', '<=', $previous->toDateTimeString())->where('end', '>=', $start->toDateTimeString())->first();
                if ($timeslot != null) {
                    //dd($timeslot);
                    //$score = array_add($score, $i, $timeslot->weighting);
                    $score[$i] += $timeslot->weighting;
                    //$score[$i] += $timeslot->weighting;
                    //$score[] = array($timeslot->weighting);
                    //$k++;
                    //var_dump($score);
                }
            }
            $previous = $start;
        }
        $score = array_filter($score);
        //dd($score);
        rsort($score);
        $top3 = array_reverse(array_slice($score, 0, 3));
        $users = Occasion::find($occasion_id)->users()->get();
        $data = array('temp');
        $users = $users->each(function ($user) use($data) {
            \Mail::send('emails.invite', $data, function ($message) use($user) {
                $message->to($user->email, $user->name)->subject('Your event has been scheduled!');
            });
            \Twilio::message($user->phone, 'An event has finished scheduling! Open up Calendr to learn more.');
        });
        $app_id = 'jVmr9Q4ItzKs2abze4T2mRvECJ8AxMwCKT5G8anC';
        $rest_key = 'hNv7GwawFKdvpyb6B6u8sLqlSQMW3YWWRQeKVll7';
        $master_key = 'wzwEOPsb5w45qWQQVJSCqTtL6yvD82Y90SiVDh4y';
        ParseClient::initialize($app_id, $rest_key, $master_key);
        $data = array("alert" => "An event has finished scheduling! Press here to learn more.");
        ParsePush::send(array("channels" => ["PHPFans"], "data" => $data));
        $query = ParseInstallation::query();
        $query->equalTo("design", "rad");
        ParsePush::send(array("where" => $query, "data" => $data));
        //	dd($score);
    }
コード例 #14
0
ファイル: test.php プロジェクト: abhiyadav001/Monkey
<?php

/* 
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
// public function sendVerification($mobile, $passcode){
$var = Twilio::message("+919711987169", "Enter  on the sign up page to verify your account. This is one time message from Couture.");
print_r($var);
// }
コード例 #15
-1
ファイル: Functions.php プロジェクト: ashishvazirani/food
 public function sendSMS($to = '', $message = '')
 {
     $to = trim($to);
     $message = trim($message);
     $msg = '';
     $raw = '';
     $sms_provider = Yii::app()->functions->getOptionAdmin('sms_provider');
     //if ($sms_provider=="nexmo"){
     $sms_provider = strtolower($sms_provider);
     //dump($sms_provider);
     switch ($sms_provider) {
         case "clickatell":
             $Clickatell = new Clickatell();
             $Clickatell->user = Yii::app()->functions->getOptionAdmin('clickatel_user');
             $Clickatell->password = Yii::app()->functions->getOptionAdmin('clickatel_password');
             $Clickatell->api_id = Yii::app()->functions->getOptionAdmin('clickatel_api_id');
             $Clickatell->is_curl = Yii::app()->functions->getOptionAdmin('clickatel_use_curl');
             $Clickatell->to = $to;
             $Clickatell->message = $message;
             $clickatel_use_unicode = Yii::app()->functions->getOptionAdmin('clickatel_use_unicode');
             if ($clickatel_use_unicode == 1) {
                 $Clickatell->unicode = true;
             }
             $clickatel_sender = Yii::app()->functions->getOptionAdmin('clickatel_sender');
             $Clickatell->sender = $clickatel_sender;
             try {
                 $raw = $Clickatell->sendSMS();
                 $msg = "process";
             } catch (Exception $e) {
                 $msg = $e->getMessage();
                 $raw = $e->getMessage();
             }
             break;
         case "nexmo":
             $nexmo_sender_id = Yii::app()->functions->getOptionAdmin('nexmo_sender_id');
             $nexmo_key = Yii::app()->functions->getOptionAdmin('nexmo_key');
             $nexmo_secret = Yii::app()->functions->getOptionAdmin('nexmo_secret');
             $nexmo_use_curl = Yii::app()->functions->getOptionAdmin('nexmo_use_curl');
             $Nexmo = new Nexmo();
             $Nexmo->key = $nexmo_key;
             $Nexmo->secret = $nexmo_secret;
             $Nexmo->sender = $nexmo_sender_id;
             $Nexmo->to = $to;
             $Nexmo->message = $message;
             $Nexmo->is_curl = $nexmo_use_curl;
             $nexmo_use_unicode = Yii::app()->functions->getOptionAdmin('nexmo_use_unicode');
             if ($nexmo_use_unicode == 1) {
                 $Nexmo->unicode = true;
             }
             try {
                 $raw = $Nexmo->sendSMS();
                 $msg = "process";
             } catch (Exception $e) {
                 $msg = $e->getMessage();
             }
             break;
         case "private":
             $privatesms_username = Yii::app()->functions->getOptionAdmin('privatesms_username');
             $privatesms_password = Yii::app()->functions->getOptionAdmin('privatesms_password');
             $privatesms_sender = Yii::app()->functions->getOptionAdmin('privatesms_sender');
             /*dump($privatesms_username);
             	 dump($privatesms_password);
             	 dump($privatesms_sender);*/
             $obj = new Sender("103.16.101.52", "80", $privatesms_username, $privatesms_password, $privatesms_sender, $message, $to, "0", "1");
             $resp = $obj->Submit();
             if (preg_match("/1701/i", $resp)) {
                 $raw = $resp;
                 $msg = "process";
             } else {
                 $errors['1702'] = "Invalid URL Error, This means that one of the parameters was not\r\n\t\t\tprovided or left blank";
                 $errors['1703'] = "Invalid value in username or password field";
                 $errors['1704'] = 'Invalid value in "type" field';
                 $errors['1705'] = "Invalid Message";
                 $errors['1706'] = "Invalid Destination";
                 $errors['1707'] = "Invalid Source (Sender)";
                 $errors['1708'] = 'Invalid value for "dlr" field';
                 $errors['1709'] = "User validation failed";
                 $errors['1710'] = "Internal Error";
                 $errors['1025'] = "Insufficient Credit";
                 $resp_temp = explode("|", $resp);
                 if (is_array($resp_temp) && count($resp_temp) >= 1) {
                     $code_error = $resp_temp[0];
                 } else {
                     $code_error = $resp;
                 }
                 if (array_key_exists($code_error, $errors)) {
                     $msg = $errors[$code_error];
                 } else {
                     $msg = "Undefined response from api.";
                 }
             }
             break;
         case "bhashsms":
             $bhashsms_user = Yii::app()->functions->getOptionAdmin('bhashsms_user');
             $bhashsms_pass = Yii::app()->functions->getOptionAdmin('bhashsms_pass');
             $bhashsms_senderid = Yii::app()->functions->getOptionAdmin('bhashsms_senderid');
             $bhashsms_smstype = Yii::app()->functions->getOptionAdmin('bhashsms_smstype');
             $bhashsms_priority = Yii::app()->functions->getOptionAdmin('bhashsms_priority');
             $bhashsms_use_curl = Yii::app()->functions->getOptionAdmin('bhashsms_use_curl');
             $Bhashsms = new Bhashsms();
             $Bhashsms->user = $bhashsms_user;
             $Bhashsms->password = $bhashsms_pass;
             $Bhashsms->sender = $bhashsms_senderid;
             $Bhashsms->sms_type = $bhashsms_smstype;
             $Bhashsms->priority = $bhashsms_priority;
             $Bhashsms->to = $to;
             $Bhashsms->message = $message;
             $Bhashsms->is_curl = $bhashsms_use_curl == 1 ? true : false;
             try {
                 $raw = $Bhashsms->sendSMS();
                 $msg = "process";
             } catch (Exception $e) {
                 $msg = $e->getMessage();
             }
             break;
         default:
             require_once "Twilio.php";
             $sms_sender_id = Yii::app()->functions->getOptionAdmin('sms_sender_id');
             $sms_account_id = Yii::app()->functions->getOptionAdmin('sms_account_id');
             $sms_token = Yii::app()->functions->getOptionAdmin('sms_token');
             $twilio = new Twilio();
             $twilio->_debug = false;
             $twilio->sid = $sms_account_id;
             $twilio->auth = $sms_token;
             $twilio->data['From'] = $sms_sender_id;
             $twilio->data['To'] = $to;
             $twilio->data['Body'] = $message;
             if ($resp = $twilio->sendSMS()) {
                 $raw = $twilio->getSuccessXML();
                 $msg = "process";
             } else {
                 $msg = $twilio->getError();
             }
             break;
     }
     return array('msg' => $msg, 'raw' => $raw, 'sms_provider' => $sms_provider);
 }