LAPTOP-V9RRD1TL\Michelle's Computer f8f8fcaf96 first commit
2025-07-21 21:38:17 +08:00

47 lines
1.5 KiB
PHP

<?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 ;
}
}
?>