Reputation: 45
The curl is giving me 500 error. How to fix 500 error ?
$msg='Phone:'.$_POST['phone'].',Email:'.$_POST['email'].',Message:'.$_POST['query'].''; // This is dynamic msg.
$urlpara="http://xxx.xxx.xxx.xx:8080/sendsms/bulksms?username=xxx&password=xxxx&type=0&dlr=1&destination=xxxx&source=xxxx&message=".$msg."";
$response = sentSmS($urlpara);
if($response){
header('Location: thankyou.html');
exit;
}else{
header('Location: thankyou.html');
exit;
}
function sentSmS($url) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_exec($ch);
return true;
}
Upvotes: 0
Views: 3418
Reputation: 2732
try debug it:
function sentSmS($url) {
$ch = curl_init();
$options = [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_USERAGENT => 'cUrl',
CURLOPT_CONNECTTIMEOUT => 10, // timeout on connect
CURLOPT_TIMEOUT => 400, // timeout on response - after 400s
CURLOPT_FRESH_CONNECT => true,
CURLOPT_VERBOSE => true,
CURLOPT_URL => $url,
CURLOPT_HEADER => 0
];
curl_setopt_array( $ch, $options);
$result = curl_exec($ch);
if (empty($result)){
$error = curl_error($ch);
$errorNumber = curl_errno($ch);
$exception = new \Exception('curl call error: '.$error, $errorNumber);
throw $exception;
}
curl_close($ch);
return $result;
}
Upvotes: 0
Reputation: 355
You return $content
in sentSmS function, from where you get it? maybe you want to return curl_exec($ch)
?
Upvotes: 1