File manager - Edit - /home/autoph/public_html/connectv1/api/v1/sms/sms.php
Back
<?php include_once("../../../cfg/db.php"); header('Content-Type: application/json; charset=utf-8'); if (!isset($_REQUEST['number']) || !isset($_REQUEST['message']) || !isset($_REQUEST['key'])) { echo json_encode(array('status' => 0, 'message' => "Insufficient parameters")); exit(); } if (trim($_REQUEST['key']) !== 'e2d0ad32eebe11ec85df00ff70631b9a') { echo json_encode(array('status' => 0, 'message' => "Invalid key")); exit(); } $arr['receiver'] = trim($_REQUEST['number']); $arr['message'] = trim($_REQUEST['message']); $arr['message'] = strtr($arr['message'], array("\n" => "\\n")); //clean // $arr['message'] = strtr($arr['message'], array("\n" => "\\n", "\r" => "\\r")); //clean $arr['uri'] = $variable['sms_api_uri']; $arr['key'] = $variable['sms_api_key']; $arr['pwd'] = $variable['sms_api_password']; $arr['body'] = $variable['sms_api_request_body']; $arr['success'] = $variable['sms_api_success_response']; $arr['http_header'] = $variable['sms_api_http_header']; switch ($arr['uri']) { case 'https://api.philsms.com/outbound/v1': // print_r(philSMS($arr)); if (philSMS($arr) == '0') { echo json_encode(array('status' => 1, 'message' => "Sms sent successfully.")); exit(); } break; case 'https://www.itexmo.com/php_api/api.php': // print_r(itextmo($arr)); if (itextmo($arr) == '0') { echo json_encode(array('status' => 1, 'message' => "Sms sent successfully.")); exit(); } break; default: echo "sms uri not found"; } function itextmo($array_data) { $replace_parameter = array( '[no]' => $array_data['receiver'], '[msg]' => $array_data['message'], '[key]' => $array_data['key'], '[pwd]' => $array_data['pwd'] ); $final_template = strtr($array_data['body'], $replace_parameter); // $headers = json_decode($array_data['http_header'], true); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $array_data['uri']); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, json_decode($final_template, true)); // if (count($headers) > 0) { // curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); // } $result = curl_exec($ch); return $result; } function philSMS($array_data) { $replace_parameter = array( '[no]' => $array_data['receiver'], '[msg]' => $array_data['message'], '[key]' => $array_data['key'], '[pwd]' => $array_data['pwd'] ); $final_template = strtr($array_data['body'], $replace_parameter); $headers = json_decode($array_data['http_header'], true); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $array_data['uri']); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $final_template); if (count($headers) > 0) { curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); } $result = curl_exec($ch); // return $result; $response = json_decode($result, true); // return $response; return $response['status'] == 201 ? 0 : $result; }
| ver. 1.4 |
.
| PHP 7.3.33 | Generation time: 0.01 |
proxy
|
phpinfo
|
Settings