0

I am integrating an SMS API in my project. My code is live and earlier it was working fine but from few days it is not responding.

I am using curl_init function in my code. After cross checking my code I found it is returning null. I tried to solve it with existing solutions but none of them worked. My code:

<?php
if($_SERVER["REQUEST_METHOD"] == "POST") {
    $mobile = $_POST["mobile"];
    $name = $_POST["name"];

    if(empty($mobile) || empty($name)) {
        $json['error'] = 'Mobile or Name is empty';
    } elseif (!empty($mobile) && !empty($name)) {
        $ch=curl_init('some url');
        $data = curl_exec($ch);
        if($data) {
            $json['success'] = 'Sent Msg';
        } elseif(empty($data)) {
            $json['error'] = 'found empty';
        }
        else {
            $json['error'] = 'Failed to Sent Msg';
        }
    } else {
        $json['error'] = 'Cannot Send Msg';
    }
    header('Content-Type: application/json');
    echo json_encode($json);
    curl_close($ch);
}
?>

Sorry due to certain reason I can't share URL here but issue is not with url because on directly hitting URL it is working fine. My above code is giving me result as: "error": "found empty" .Can anyone let me know what I am doing wrong? Thanks for your help.

0 Answers0