Advertisement
craftyoyo

Untitled

Aug 18th, 2017
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.24 KB | None | 0 0
  1. <?php
  2. function sendSMS($message)
  3. {
  4. $post = "Message de:";
  5. $post .= $_GET["nom"];
  6. $post .= ' - Msg:';
  7. $post .= $_GET["message"];
  8.     //config
  9.     $username = '****';
  10.     $password = '**********';
  11.     //config
  12.    
  13.     $url = 'https://smsapi.free-mobile.fr/sendmsg?user='.$username.'&pass='.$password.'&msg='.$post;
  14.     $curl = curl_init();
  15.     curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
  16.     curl_setopt_array($curl, array(
  17.         CURLOPT_RETURNTRANSFER => 1,
  18.         CURLOPT_URL => $url
  19.     ));
  20.  
  21.     $httpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
  22.     if($httpCode == 404) {
  23.         echo '404 serverside, check your username or password.';
  24.     }
  25.     elseif($httpCode == 200) {
  26.         echo 'Message envoyé.';
  27.     }
  28.     elseif($httpCode == 400) {
  29.         echo 'Missing parameter.';
  30.     }
  31.     elseif($httpCode == 402) {
  32.         echo 'Too many SMS sent, please wait.';
  33.     }
  34.     elseif($httpCode == 403) {
  35.         echo 'Service not enabled on your account.';
  36.     }
  37.     elseif($httpCode == 500) {
  38.         echo 'Freemobile server error, please try again later.';
  39.     }
  40.     else
  41.     {
  42.         if(curl_exec($curl) === false)
  43.         {
  44.             echo 'Curl error: ' . curl_error($curl);
  45.         }
  46.         else
  47.         {
  48.             //echo 'ok!';
  49.         }
  50.     }
  51.     curl_close($curl);
  52. }
  53.  
  54.  
  55.  
  56. sendSMS('Yay, working !');
  57. header("Location: /index.php?code='. curl_error($curl) .'");
  58. die();
  59. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement