HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux WebLive 5.15.0-79-generic #86-Ubuntu SMP Mon Jul 10 16:07:21 UTC 2023 x86_64
User: ubuntu (1000)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/html/wpprotonperinggit/wp-content/plugins/wp-cardealer/includes/sms/class-sms-aws.php
<?php
/**
 * Agent
 *
 * @package    wp-cardealer
 * @author     Habq 
 * @license    GNU General Public License, version 3
 */

if ( ! defined( 'ABSPATH' ) ) {
  	exit;
}


use Aws\Sns\SnsClient; 
use Aws\Exception\AwsException;
use Aws\Credentials\Credentials;

class WP_CarDealer_SMS_Aws {
	
	protected static $_instance = null;
	private $credentials;

	public function __construct(){
		$this->set_credentials();
	}

	public static function get_instance(){
		if ( is_null( self::$_instance ) ) {
			self::$_instance = new self();
		}
		return self::$_instance;
	}


	private function set_credentials(){
		$access_key = wp_cardealer_get_option( 'phone_approve_aws_access_key' );
		$secret_key = wp_cardealer_get_option( 'phone_approve_aws_secret_access_key' );
		$this->credentials = new Credentials(
			$access_key,
			$secret_key
		);

	}

	public function sendSMS( $phone, $message ){
		$SnSclient = new SnsClient([
		    'credentials' 	=> $this->credentials,
		    'region' 		=> 'us-east-1',
		    'version' 		=> 'latest'
		]);

		try {
		    $result = $SnSclient->publish([
		        'Message' => $message,
		        'PhoneNumber' => $phone,
		    ]);
		} catch (AwsException $e) {
		    // output error message if fails
		    return new WP_Error( 'operator-error', $e->getMessage() );
		} 

	}

}