2016-11-30 4 views
0

Я отправляю сообщения через sms api с помощью PHP Script. СМС отправляются Успешно, но у меня проблема в моем сообщении. Сценарий Php, предоставляющий только сообщение «ThankYou», остается на мобильном устройстве.Отправка sms из PHP Script

$message1="ThankYou '$email' you are succesfully booked your service.Your booking details Booking Date = '$date'Booking Location='$location'"; 

Мой PHP скрипт:

<?php 

require 'PHPMailer/PHPMailerAutoload.php'; 
require "init.php"; 
    $email=$_POST['email']; 
    $bikeno=$_POST['bikeno']; 
    $location=$_POST['location']; 
    $date=$_POST['date']; 
    $mobileno=$_POST['mobileno']; 
    $sql="select * from book_order where location ='".$location."' and date ='".$date."';"; 
    $result=mysqli_query($con,$sql); 
    $response =array(); 
    if(mysqli_num_rows($result)>=20) 
    { 
    $code="reg_failed"; 
    $message="Sorry For that Selected Date or Service Centre Is also Booked try with another Date or Service centre"; 
array_push($response,array("code"=>$code,"message"=>$message)); 
echo json_encode($response);  
    } 
    else { 
$sql="insert into book_order(email,bikeno,location,date,mobileno) values ('".$email."','".$bikeno."','".$location."','".$date."','".$mobileno."');"; 
$result=mysqli_query($con,$sql); 
$code="reg_success"; 
$message="Thanks for choose use for serve you better."; 
array_push($response,array("code"=>$code, "message"=>$message)); 
echo json_encode($response); 
    if($sql) 
{ 
$message1="ThankYou '$email' you are succesfully booked your service.Your   booking details Booking Date = '$date'Booking Location='$location'"; 


    $URL = "http://ptms.bulksmshyderabad.in/API/sms.php?username=xxxx&password=xxxx&from=YAMAHA&to=$mobileno&msg=$message1&type=1&dnd_check=0"; 
    $ch = curl_init(); 


curl_setopt($ch, CURLOPT_URL, $URL); 
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_fields); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 

    $result=curl_exec($ch); 


    }  

    } 


    mysqli_close($con); 
    ?> 
+0

$ message1 = "ThankYo + '$ email + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + $ местоположение "+"; –

ответ

1

Вы недопустимые символы (т.е. ') в URL. Сервер SMS не может правильно разобрать ваше SMS-сообщение. Используйте следующий код, чтобы сделать строку запроса безопасной/действительной для запроса GET.

$message1 = "..."; // Your original message 
$safeMessage = urlencode($message1); 

Конечно, вам нужно использовать $safeMessage при назначении значения $URL.

Дополнительные примечания:

  • Pls рассмотреть возможность удаления чувствительное верительных от вопроса, то есть реальное имя пользователя и пароль в URL.
  • Ваш запрос curl формирует запрос POST, однако запрос GET кажется достаточным, потому что API может получить всю информацию с URL-адреса.
Смежные вопросы