Changeset 2676477
- Timestamp:
- 02/10/2022 03:44:54 PM (4 years ago)
- Location:
- wp-sms-functions/trunk
- Files:
-
- 3 edited
-
inc/providers/Gri_Provider.php (modified) (8 diffs)
-
readme.txt (modified) (1 diff)
-
wp-sms-functions.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
wp-sms-functions/trunk/inc/providers/Gri_Provider.php
r2640751 r2676477 12 12 $this->slug = 'Gri'; 13 13 $this->name = 'Gri SMS'; 14 $this->api_base_url = 'https://sms-api .gri.net';14 $this->api_base_url = 'https://sms-api2.gri.net'; 15 15 16 16 add_filter('Smsfunctions_providers', function ($prov) { … … 53 53 $secret_key = $options['gri_secret_key']; 54 54 return array( 55 'Authorization' => 'Basic ' . base64_encode($api_key . ':' . $secret_key) 55 'Authorization' => 'Basic ' . base64_encode($api_key . ':' . $secret_key), 56 'Content-Type' => 'application/json' 56 57 ); 57 58 } … … 65 66 66 67 $post_fields = json_encode(array( 67 'from' => $header, 68 'msg' => $message, 69 'to' => $gsmNo, 70 'lang' => explode('_', get_locale())[0] 68 'header' => $header, 69 'message' => $message, 70 'phone' => $gsmNo 71 71 ), JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); 72 72 … … 74 74 75 75 try { 76 $request = parent::wpPost($this->api_base_url . '/ send-sms', $post_fields, $authentication);76 $request = parent::wpPost($this->api_base_url . '/SendSms', $post_fields, $authentication); 77 77 $response = json_decode($request); 78 78 79 if ($response->status === false) 80 throw new Exception(isset($response->details) ? $response->details : 'An error occurred!'); 79 $errors = array(); 80 if (isset($response->errors)) { 81 foreach ($response->errors as $error) 82 { 83 $errors[] = implode(" - " , $error); 84 } 85 throw new Exception( count( $errors ) ? implode("\n", $errors) : 'An error occurred!' ); 86 } 81 87 } catch (Exception $ex) { 82 88 throw $ex; … … 92 98 $is_tokens = !empty($options['gri_api_key']) && !empty($options['gri_secret_key']); 93 99 if ($selected_provider === 'gri') { 94 $request = parent::wpGet($this->api_base_url . '/ get-headers', array(), $this->getAuthentication());100 $request = parent::wpGet($this->api_base_url . '/Headers', array(), $this->getAuthentication()); 95 101 $response_for_sms_headers = json_decode($request); 96 102 97 if (! $response_for_sms_headers->status) {103 if (!is_array($response_for_sms_headers) && isset($response_for_sms_headers->message)) { 98 104 echo "<strong style='color:red'>" . 99 $response_for_sms_headers-> details.105 $response_for_sms_headers->message . 100 106 "</strong>"; 101 107 } … … 116 122 /></td> 117 123 </tr> 118 <?php if (is set($response_for_sms_headers) && $response_for_sms_headers->status): ?>124 <?php if (is_array($response_for_sms_headers) && count($response_for_sms_headers)): ?> 119 125 <tr> 120 126 <th><?php esc_html_e('SMS Header', 'wp-sms-functions') ?></th> … … 128 134 <option value=""><?php esc_html_e('Select', 'wp-sms-functions'); ?></option> 129 135 <?php 130 foreach ($response_for_sms_headers ->detailsas $header) {136 foreach ($response_for_sms_headers as $header) { 131 137 $selected = ($options['gri_msg_header'] == $header) ? 'selected' : ''; 132 138 … … 146 152 esc_html_e('You must save api key and secret key to view the balance.', 'wp-sms-functions'); 147 153 } else { 148 $request = parent::wpGet($this->api_base_url . '/ get-balance', array(), $this->getAuthentication());154 $request = parent::wpGet($this->api_base_url . '/Balance', array(), $this->getAuthentication()); 149 155 $response_for_balance = json_decode($request); 150 if ($response_for_balance-> status) {151 esc_html_e($response_for_balance-> details);156 if ($response_for_balance->Balance) { 157 esc_html_e($response_for_balance->Balance); 152 158 } else { 153 159 esc_html_e('There is no balance defined for you. Please contact us!', 'wp-sms-functions'); -
wp-sms-functions/trunk/readme.txt
r2640749 r2676477 46 46 == Changelog == 47 47 48 = 1.2.5 = 49 * Gri SMS provider updated. 50 48 51 = 1.2.4 = 49 52 * Gri SMS provider added. -
wp-sms-functions/trunk/wp-sms-functions.php
r2640749 r2676477 6 6 * Author URI: https://www.gri.net 7 7 * Text Domain: wp-sms-functions 8 * Version: 1.2. 48 * Version: 1.2.5 9 9 * Domain Path: /lang 10 10 * Requires at least: 4.9
Note: See TracChangeset
for help on using the changeset viewer.