-1

here is my configuration : Apache2 working with php7.1.

I have an example PHP code for sending a sms message specific to JasminSMS :

<?php
// Sending simple message using PHP
// http://jasminsms.com

$baseurl = 'http://127.0.0.1:1401/send'

$params = '?username=foo'
$params.= '&password=bar'
$params.= '&to='.urlencode('+336222172')
$params.= '&content='.urlencode('Hello world !')

$response = file_get_contents($baseurl.$params);
?>

But it does not working and give me error 500.

I have two examples that works well:

http://127.0.0.1:1401/send?username=foo&password=bar&to=06222172&content=hello

and

curl -d "username=foo&password=bar&dlr=yes&dlr-level=3&to=xxxxxxxxxx&from=InfoMessage&dlr-url=http://exemple.com/dlr.php&content=hello !" http://127.0.0.1:1401/send

I need to turn them into php queries and found them next exemples :

<?php
$ch = curl_init("http://127.0.0.1:1401/send");
$fp = fopen("username=foo&password=bar&dlr=yes&dlr-level=3&to=xxxxxxxxxx&from=InfoMessage&dlr-url=http://exemple.com/dlr.php&content=hello !", "w");

curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_HEADER, 0);

curl_exec($ch);
curl_close($ch);
fclose($fp);
?>


<?php
 $ch = curl_init('http://127.0.0.1:1401/send?username=foo&password=bar&to=xxxxxxxxxx&content=hello !');
 curl_exec ($ch);
 curl_close ($ch);
?>

that I found here :

Sending POST form data with php CURL, api-http-examples-php and I tested all these examples without result, all show me 500 error.

Maybe it needs to configure .htaccess, my file permissions are 755 with www-data.

Thanks for any help.

3
  • 1
    What is in your apache error.log ? 500 errors are internal server errors and indicate a problem with your script (typically)
    – ivanivan
    Apr 25, 2018 at 12:25
  • I'v got these error : Got error 'PHP message: PHP Fatal error: Uncaught Error: Call to undefined function curl_init() in /var/www/html/yip2.php:2\nStack trace:\n#0 {main}\n thrown in /var/www/html/yip2.php on line 2\n' for the second example.
    – hexphp111
    Apr 25, 2018 at 12:30
  • 1
    You need to add curl support to your PHP setup. How to do this will depend on what distro you are running...
    – ivanivan
    Apr 25, 2018 at 12:39

1 Answer 1

2

There is no php-curl installed on your machine. You should install it. Installation depends on your OS.

More details about your error could be found in this answer.

2
  • Thank you, it's working after installing this: 'apt-get install php7.1-curl' , I must now make an input form from this : '<?php $ch = curl_init("127.0.0.1:1401/send"); curl_setopt ($ch, CURLOPT_POST, 1); curl_setopt ($ch, CURLOPT_POSTFIELDS, "username=foo&password=bar&dlr=yes&dlr-level=3&to=xxxxxxxxxxfrom=InfoMessage&dlr-url=example.com/dlr.php&content=hello !); curl_exec($ch); curl_close($ch); ?>' - Any idea ?
    – hexphp111
    Apr 26, 2018 at 11:30
  • @hexphp111 just create form - here more docs. Apr 26, 2018 at 17:57

Not the answer you're looking for? Browse other questions tagged .