Current Location: Home> Latest Articles> PHP Code Example: How to Send SMS Using S05GK API

PHP Code Example: How to Send SMS Using S05GK API

gitbox 2025-06-30

Introduction

The S05GK API is an SMS sending interface based on the HTTP protocol, which enables sending SMS messages to mobile phones via HTTP requests. This article explains how to use PHP code to send SMS through the S05GK API.

Apply for the API

Before using the S05GK API, you need to apply for access. The application process is as follows:

  • Visit the official S05GK website to obtain the application link.
  • Fill in the application form with your company name, contact person, phone number, etc.
  • Submit the application and wait for approval.

Obtain the API Documentation

Once your application is approved, S05GK will provide the API documentation, which includes the API endpoint, required parameters, and example code, helping you quickly understand how to use the API.

PHP Code for Sending SMS

Below is an example of using PHP code to send SMS via the S05GK API:


$url = 'http://api.s05gk.com:8888/sms/send';
$post_data = array(
    'user_id' => 'User ID',
    'password' => 'User Password',
    'mobile' => 'Mobile Number',
    'content' => 'SMS Content',
    'send_time' => 'Send Time',
    'extno' => 'Extension Code',
    'sign' => 'Signature',
    'format' => 'json',
);
$post_data = http_build_query($post_data);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
curl_close($ch);
$response = json_decode($result, true);

In the above code, you need to replace the corresponding parameters such as User ID, User Password, Mobile Number, SMS Content, etc. Please fill in these based on your actual needs.

Explanation of Parameters

The parameters in the code represent the following:

  • user_id: User ID provided by S05GK.
  • password: User password provided by S05GK.
  • mobile: The mobile number where the SMS will be sent.
  • content: The content of the SMS to be sent.
  • send_time: Optional parameter, used if you want to schedule the SMS. If not needed, you can leave it blank.
  • extno: Optional parameter, used if you need an extension code. You can leave it blank if not used.
  • sign: Optional parameter, used for SMS signature. Leave it blank if you don't need it.
  • format: The format of the response data. You can choose from json, xml, or txt format. The default is json.

Conclusion

By following the above steps, you can easily integrate the S05GK SMS sending API using PHP code. The S05GK API is simple to use and convenient for developers, making it one of the most commonly used SMS APIs in web development.