7 Replies - 1033 Views - Last Post: 27 February 2014 - 07:49 AM Rate Topic: -----

#1 mutago234   User is offline

  • D.I.C Regular

Reputation: 1
  • View blog
  • Posts: 260
  • Joined: 08-September 13

sms sending in php not working

Posted 25 February 2014 - 10:18 PM

I bought an SMS unit and try to use CURL in PHP but the code returns error shown below

Not Acceptable

An appropriate representation of the requested resource /components/com_spc/smsapi.php could not be found on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
Apache/2.2.26 (Unix) mod_ssl/2.2.26 OpenSSL/1.0.1e-fips DAV/2 mod_bwlimited/1.4 Server at www.cksms.com Port 80

they suggested to disable mod_security but i don't have it installed
below is the entire code
<?php
if(isset($_POST['submit'])){
	
	
    // Configuration variables
    $info = "1";
    $test = "0";
	
$username = $_POST['username'];
$password = $_POST['password'];
$sender = $_POST['sender'];
        $recipient = $_POST['recipient'];
        $message = $_POST['message'];
    $message = urlencode($message);


//array('user'=>'<USERNAME>', ....);

$data = array(
        'username' => $_POST['username'],
        'password' => $_POST['password'],
        'sender'  => $_POST['sender'],
'recipient'  => $_POST['recipient'],
		'message'  => $_POST['message']
);


    // Prepare data for POST request
   //$data = "username=".$username."&password=".$password."&message=".$message."&sender=". $sender."&recipient=".$recipient."&info=".$info."&test=".$test; 

    // Send the POST request with cURL
    $ch = curl_init('http://www.cksms.com/components/com_spc/smsapi.php');
    curl_setopt($ch, CURLOPT_POST, true);

    curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
	
	//curl_setopt($ch, CURLOPT_POSTFIELDS, "username=".$username."&password=".$password."&message=".$message."&sender=". $sender."&recipient=".$recipient."&info=".$info."&test=".$test);
    //curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
 curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
    $result = curl_exec($ch); //This is the result from Textlocal


if(curl_exec($ch) === false) {
echo '<font color=red size=4><b>Message sending failed' . '</b></font><br />';
} else {
echo '<font color=orange size=4><b>Message sent successfully' . '</b></font><br />';
echo 'Total number of bytes downloaded: ' . curl_getinfo($ch,CURLINFO_SIZE_DOWNLOAD) . '<br />';
echo 'Total size of all headers received: ' . curl_getinfo($ch,CURLINFO_HEADER_SIZE) . '<br />';
}

curl_close($ch);

//var_dump($result);

print($result);
} else {




?>
 

                <form method="post"  style="margin: 5px; padding: 5px;">
                        <table width="100%" border="0" cellspacing="5px" cellpadding="3px">
     
     <tr>
                             
                                <td><input name="username" type="hidden" id="username" value="myUserName" size="50" style="width: 400px;" /></td>
                        </tr>
                        <tr>
                                
                                <td><input name="password" type="hidden" id="password" value="myPassword" size="50" style="width: 400px;" /></td>
                        </tr>                   
<tr>
                                <td>Sender</td>
                                <td><input name="sender" type="text" id="sender" size="50" style="width: 400px;" /></td>
                        </tr>
<tr>
                                <td>Reciever</td>
                                <td>

<input name="recipient" type="text" id="recipient" size="50" style="width: 400px;" value="<?php echo $va1; ?>"/>


</td>
                        </tr>


                        <tr>
                                <td>Message</td>
                                <td><textarea name="message" rows="4" cols="90" id="message" style="width: 400px; height: 120px;"></textarea></td>
                        </tr>
                        
                        <tr>
                                <td> 

                                <td><input type="submit" name="submit" id="add_subcat" value="Send Now!" class="btn btn-info btn-small"></input> <input type="reset" name="Submit2" value="Reset" /></td>
                        </tr>
                </table>
                </form>
<?php
}
?>


This post has been edited by modi123_1: 26 February 2014 - 07:47 AM
Reason for edit:: hide name and password


Is This A Good Question/Topic? 0
  • +

Replies To: sms sending in php not working

#2 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 14486
  • View blog
  • Posts: 58,055
  • Joined: 12-June 08

Re: sms sending in php not working

Posted 25 February 2014 - 10:25 PM

Quote

An appropriate representation of the requested resource /components/com_spc/smsapi.php could not be found on this server.


Does this:
032	    $ch = curl_init('http://www.cksms.com/components/com_spc/smsapi.php');


actual exist? I tried hitting it and got a domain reseller site.
Was This Post Helpful? 0
  • +
  • -

#3 Atli   User is offline

  • Enhance Your Calm
  • member icon

Reputation: 4240
  • View blog
  • Posts: 7,216
  • Joined: 08-June 10

Re: sms sending in php not working

Posted 25 February 2014 - 11:53 PM

Quote

I bought an SMS unit

What does that mean, exactly? What did you buy?
Was This Post Helpful? 0
  • +
  • -

#4 mutago234   User is offline

  • D.I.C Regular

Reputation: 1
  • View blog
  • Posts: 260
  • Joined: 08-September 13

Re: sms sending in php not working

Posted 26 February 2014 - 02:25 AM

message sent to ATL and modi123_1 as username and password cannot be public
Was This Post Helpful? 0
  • +
  • -

#5 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 14486
  • View blog
  • Posts: 58,055
  • Joined: 12-June 08

Re: sms sending in php not working

Posted 26 February 2014 - 07:48 AM

FYI - then edit out your name and password when you post your code. If you forgot you can use the 'report' button on the post and put in a small message about what you need changed and any moderator will get to it.
Was This Post Helpful? 0
  • +
  • -

#6 ArtificialSoldier   User is offline

  • D.I.C Lover
  • member icon

Reputation: 2147
  • View blog
  • Posts: 6,522
  • Joined: 15-January 14

Re: sms sending in php not working

Posted 26 February 2014 - 10:13 AM

$username = $_POST['username'];
$password = $_POST['password'];
$sender = $_POST['sender'];
        $recipient = $_POST['recipient'];
        $message = $_POST['message'];
    $message = urlencode($message);


//array('user'=>'<USERNAME>', ....);

$data = array(
        'username' => $_POST['username'],
        'password' => $_POST['password'],
        'sender'  => $_POST['sender'],
'recipient'  => $_POST['recipient'],
    'message'  => $_POST['message']
);


What the point of saving all of those values from $_POST into other variables if you don't use them? You also have variables called $info and $test which never get used, and you're trying to print a variable called $va1 in the form that isn't defined.

The URL http://www.cksms.com..._spc/smsapi.php definitely returns a 404 and then redirects. I don't know if the server is set up to return a 404 if you aren't logged in, but that would be an unusual response. A 403 is more appropriate for that, or just an error page stating the situation. It sounds to me like you're not using the correct URL, and the 404 response you're receiving is accurate.
Was This Post Helpful? 0
  • +
  • -

#7 Atli   User is offline

  • Enhance Your Calm
  • member icon

Reputation: 4240
  • View blog
  • Posts: 7,216
  • Joined: 08-June 10

Re: sms sending in php not working

Posted 26 February 2014 - 05:37 PM

View Postmutago234, on 26 February 2014 - 09:25 AM, said:

message sent to ATL

It's Atli, thank you very much. I also don't answer technical questions through PM, on principle. Like modi123_1 says, you can post the code here and just replace the confidential info with example values.
Was This Post Helpful? 0
  • +
  • -

#8 mutago234   User is offline

  • D.I.C Regular

Reputation: 1
  • View blog
  • Posts: 260
  • Joined: 08-September 13

Re: sms sending in php not working

Posted 27 February 2014 - 07:49 AM

resolved. its a browser issues though all the unused Post variables are now removed. it works perfect now.


Thank You
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1