Hi, I am working on this curl function.The problem is it is not executing.

1)When we use $URL value directly in browser its working fine & SMS is going to number.
2)When i am trying to call a function having some curl function its not working.
Need help.
Thanks

<?php
    function sendSMS($mobile, $msg, $sender, $sendPass, $sendID)
    {
        $msg=urlencode($msg);
        $ch = curl_init();
        $url="abksms.com/pushsms.php?username=cs&password=6117&sender=SHRDATIA&to=$mobile&message=$msg";
        //echo $url;
        //$url=urlencode($url);
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_HEADER, 0);
        curl_setopt($ch, CURLOPT_POST, 1)or die("error1");
        curl_setopt($ch, CURLOPT_POSTFIELDS, $curlPost);
        $data = curl_exec($ch);
        curl_close($ch);
        return $data;
        //return substr($data,0,1);
    }
   
   
    // call function on form submition
   
    sendSMS("9210485810","Hi! Type Your Message Here","ks","6917","SHRDATIA");
   
    //pass varaible
    sendSMS($mobileno, $msg, $user, $pass, $senderid);
?>

Recommended Answers

All 5 Replies

provid the protocol in the url as well: $url="[B]http://[/B]abksms.com...";

Thanks for replying.

Which protocol.
Could you please give me any example.

Which protocol?

http:// (I even hightlighted it for you. Basically what you have in line 6 is incomplete).

It still not working.
When we copy $url value in url its working otherwise this curl function is not execuiting.

When we copy $url value in url its working

That tells me that the remote script works with a GET request. On your post, comment out lines 12 AND 13. You are really NOT POSTing anything, since:
a. $curlPost is not defined anywhere in that function
b. again, based on your last comment, the script works with GET not POST

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.