0

I tried to send an SMS from my PHP website to a mobile phone using the BulkSMS API. I used the code below, but I don't know what went wrong. I didn't receive the SMS and nothing is showing up in the browser, just a blank page .

<?php 
$url = 'http://bulksms.vsms.net/eapi/submission/send_sms/2/2.0';
$to=some number;
$username = 'usernme';
$password = 'password';
$sender='BBMS';
$msisdn = '+968'.$to;
$content="Test";
function do_post_request($url, $data, $optional_headers = 'Content-type:application/x-www-form-urlencoded'){
$params = array('http' => array(
          'method' => 'POST',
          'content' => $data
        ));
if ($optional_headers !== null) {
$params['http']['header'] = $optional_headers;
 }
 $ctx = stream_context_create($params);
  $fp = @fopen($url, 'rb', false, $ctx);
 if (!$fp) {
   throw new Exception("Problem with $url, $php_errormsg");
   }
   $response = @stream_get_contents($fp);
   if ($response === false) {
     throw new Exception("Problem reading data from $url, $php_errormsg");
   }
    return $response;

   var_dump($response);

    }

     ?>
Arwa
  • 1
  • 2
  • Provide please some additional information such as error logs or exceptions that are returned from server – nKognito May 08 '15 at 11:26
  • actually nothing is showing up only a blank white page ... i used xampp as a server – Arwa May 08 '15 at 12:13
  • Is your `do_post_request` function being called? – devqon May 08 '15 at 12:19
  • when i called do_post_request this error is shown – Arwa May 08 '15 at 12:31
  • Fatal error: Uncaught exception 'Exception' with message 'Problem with http://bulksms.vsms.net/eapi/submission/send_sms/2/2.0, fopen(http://bulksms.vsms.net/eapi/submission/send_sms/2/2.0): failed to open stream: php_network_getaddresses: getaddrinfo failed: This is usually a temporary error during hostname resolution and means that the local server did not receive a response from an authoritative server. ' in C:\xampp\htdocs\sms.php:25 Stack trace: #0 C:\xampp\htdocs\sms.php(36): do_post_request('http://bulksms.'username=ibrica...') #1 {main} thrown in C:\xampp\htdocs\sms.php on line 25 – Arwa May 08 '15 at 12:32
  • have you tried this link. http://developer.bulksms.com/eapi/code-samples/php/send_sms/. Official code to send sms using bulksms.com.. The function which you are using is not same over there. – Mahendran Sakkarai May 08 '15 at 13:27
  • yah i check that link before but i didn't know how to use the methods coz i'm a beginner :( – Arwa May 09 '15 at 05:37

0 Answers0