0

I am trying to send SMS after the leads submission, but somewhere I am doing mistake, here is my code:

if($after_query_is_insered) {
    $authKey = "xxxxxxxxxxxxxxxxxxxxxxx";
    $mobileNumber = $mobile;
    $message = "Thank you";
    $senderId = "Umar";
    $route = "4";
    $country = "0";

    $postData = array(
        'authkey' => $authKey,
        'mobiles' => '79822xxxx',
        'message' => $message,
        'sender' => $senderId,
        'route' => $route,
        'country' => $country
    );

    $url="http://bulksmsc.com/api/sendhttp.php";
    $ch = curl_init();
    curl_setopt_array($ch, array(
        CURLOPT_URL => $url,
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_POST => true,
        CURLOPT_POSTFIELDS => $postData
        //,CURLOPT_FOLLOWLOCATION => true
    ));

    //Ignore SSL certificate verification
    //curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
    //curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);

    $output = curl_exec($ch);
    if(curl_errno($ch))
    {

        echo 'error:' . curl_error($ch);
    }
    curl_close($ch);
    // echo $output; die;
}

This is my code where I am checking whether the lead is submitted to database, if it is submitted then I am trying to send the message, and I have to remain on the same page, so that other important queries run. Normally when I directly put my api into browser and send the message, it works. But here I can't use anchor to directly set the message as I will be redirected to another page. I am on Localhost. It is not working out. I have also tried to change the port to 8089, but it failed. Is there any way to do this?

Umar
  • 990
  • 1
  • 8
  • 19
  • mysql_query is deprecated. Use mysqli_query or better PDO. – Giacomo M Jul 25 '19 at 14:10
  • That's is fine, but help me where I am getting wrong in the SMS functionality. Since I am using php version 5, mysql_query is working fine, but I do understand to use PDO. – Umar Jul 25 '19 at 14:12
  • I understand, but my question is here, I want to know where I am doing mistake while implementing the functionality. I don't understand why people down vote? – Umar Jul 25 '19 at 14:22
  • And how could it be possible duplicate of "Why should not I use mysql"? Here I ddin't ask that question or related to that.@Dharman. Please read my question first. – Umar Jul 25 '19 at 14:24
  • 1
    The reason for the duplicate is that it will be very difficult to get actual help here for something that has been deprecated for the past 6 years or more. Your asking about a problem with very old code and the immediate solution is to upgrade. If for some strange reason you can't upgrade then you should make this point very clear in your question. – Dharman Jul 25 '19 at 14:31
  • For us looking at this question the problem is that it can't be executed due to the API which has been removed from the language years ago. How could we reproduce your problem? – Dharman Jul 25 '19 at 14:33
  • Read the description of [tag:api]. It says do not use! – Dharman Jul 25 '19 at 14:34
  • Now you should be fine. My question was very clear from the heading, – Umar Jul 25 '19 at 14:35
  • I know that you have the 2 lines commented out, but you should never switch SSL verification off. Just a heads-up. – Dharman Jul 25 '19 at 14:38
  • It is not specific about how to use a particular api. but this should be your point to downvote my question, not possible duplicate of mysql_query. Thank you. Now I understand your point. – Umar Jul 25 '19 at 14:39
  • Switching on that line do not work – Umar Jul 25 '19 at 14:40
  • 1
    "failed" how exactly? What goes wrong, specifically? An error message? Unexpected behaviour? Unexpected data somewhere? P.S. This server-side code has nothing to do with "remaining on the same page" as you mentioned - that's something you deal with in the browser, by using an AJAX request instead of a form postback or hyperlink click – ADyson Jul 25 '19 at 14:42

0 Answers0