first commit
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
class Sms {
|
||||
|
||||
private $endpoint = SMSENDPOINT ;
|
||||
private $id = SMSID ;
|
||||
private $token = SMSTOKEN ;
|
||||
private $secret = SMSSECRET ;
|
||||
private $company = SMSCOMPANY ;
|
||||
|
||||
public $to = '' ;
|
||||
public $message = '' ;
|
||||
|
||||
public function send() {
|
||||
|
||||
$curl = curl_init();
|
||||
|
||||
curl_setopt_array($curl, array(
|
||||
CURLOPT_URL => $this->endpoint,
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_ENCODING => '',
|
||||
CURLOPT_MAXREDIRS => 10,
|
||||
CURLOPT_TIMEOUT => 0,
|
||||
CURLOPT_FOLLOWLOCATION => true,
|
||||
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
|
||||
CURLOPT_CUSTOMREQUEST => 'POST',
|
||||
CURLOPT_POSTFIELDS => 'user_id='.urlencode( $this->id ).'&token='.urlencode( $this->token ).'&sign='.urlencode( md5( $this->id . $this->token . $this->secret ) ).'&company=' . urlencode( $this->company ) . '&to='.urlencode( '+'.str_replace( [ '-', '+' ], '', $this->to ) ).'&msg='.urlencode( $this->message ),
|
||||
CURLOPT_HTTPHEADER => array( 'Content-Type: application/x-www-form-urlencoded' ),
|
||||
));
|
||||
|
||||
$response = curl_exec($curl);
|
||||
|
||||
curl_close($curl);
|
||||
|
||||
$result = json_decode( $response, true ) ;
|
||||
|
||||
saveLog( 'sms', 'Sms', 'user_id='.urlencode( $this->id ).'&token='.urlencode( $this->token ).'&sign='.urlencode( md5( $this->id . $this->token . $this->secret ) ).'&company=' . urlencode( $this->company ) . '&to='.urlencode( '+'.str_replace( [ '-', '+' ], '', $this->to ) ).'&msg='.urlencode( $this->message ), $result ) ;
|
||||
|
||||
if ( $result['status'] == '200' ) {
|
||||
return true ;
|
||||
}
|
||||
return false ;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user