Forum Moderators: coopster
<?
$login = 'demo';
$password = 'demo';
$clientid = 'clientidcode';
$sender = 'Demo Acc';
$message_type = 'TEXT';
$receiver = '1234567890123';
$message = 'This is a test message thru curl';
$formdata = 'login=' . urlencode($login) . '&password=' . urlencode($password) . '&clientid=' . urlencode($clientid) . '&sender=' . urlencode($sender) . '&message_type=' . urlencode($message_type) . '&receiver=' . urlencode($receiver) . '&message=' . urlencode($message);
$ch=curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://127.0.0.1:8080/server/sendsms/?');
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $formdata);
$response=curl_exec($ch);
curl_close($ch);
print $response;
?>
[edited by: coopster at 2:28 pm (utc) on Feb. 3, 2009]
[edit reason] generalized specfics [/edit]
It doesn't matter what language you're doing this in, curl will always spit out stats via command line when run. I would venture to guess something in curl is balking at the request, OR the recipient of the request is returning an empty response. An example, if you curl a secure credit card processor, and the request doesn't come from an SSL-enabled site, it will return an empty string, leaving $response blank.
Try running it from the command line . . .
php -f full/path/to/yourscript.php
Barring that, see what you can get from curl_get_info() [us2.php.net]