cUrl problem
Posted: Fri Jan 27, 2012 3:58 am
Hi,
I'm send data to an external site like this:
The response from http://www.domain.com/page.php according to firebug is:
So the script is echoing the return value from the external page, whereas I only want the json returned. Is there a way to stop the response from the external page actually printing... or am I going about this entirely the wrong way?
I'm send data to an external site like this:
Code: Select all
$('#testMobile').live('click', function(e) {
e.preventDefault();
$.ajax({
url: 'includes/XXXXXXXXXXXXXXXXXX/Process.php',
dataType: 'json',
type: 'POST',
async: 'false',
data: "mobile=" + $('#mobile').val() + "&testMobileFormID=" + $("#testMobileFormID").val(),
success: function(data) {
alert("Success");
},
error: function(jqXHR, textStatus, errorThrown) {
alert("error");
}
});
});
// includes/XXXXXXXXXXXXXXXXXX/Process.php
if ($_SESSION['testMobileFormID'] == $_POST['testMobileFormID']) {
$mobile=$_POST['mobile'];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://www.domain.com/page.php');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, array('action'=>'sendsms','user'=>'XXX','password'=>'XXX','to'=>$mobile,'text'=>'TestMessage','api'=>'1','userfield'=>'6172'));
//$result = curl_exec ($ch);
$return_arr = array("status" => "success", "message" => curl_exec ($ch));
}
else {
$return_arr = array("status" => "failed", "message" => "failed");
}
echo json_encode($return_arr);
Code: Select all
OK: 0; Sent queued message ID: 59d0a4044144b710 SMSGlobalMsgID:6870910098019016
{"status":"success","message":true}