<?php
namespace App\Http\model;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
class Sms
{
private $api_key = 'api:key-99ad26d3e050041f9ea0b5c21b0a6dc2';
public function sendSMS( $mobile, $msg )
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://sms-api.luosimao.com/v1/send.json");
curl_setopt($ch, CURLOPT_HTTP_VERSION , CURL_HTTP_VERSION_1_0 );
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 8);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_HTTPAUTH , CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_USERPWD , $this->api_key);
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, array('mobile' => $mobile,'message' => $msg));
$res = curl_exec( $ch );
curl_close( $ch ); return $res;
}
public function __get($name)
{
return $this->$name;
}
public function __set($name, $value)
{
$this->$name = $value;
}
}