문자

관리툴, 엑셀 대량 발송, API 연동 등 다양한 방법으로 발송 가능한 문자 서비스입니다.

API 개발 가이드

별도의 구축 비용 없이 다양한 언어의 API 개발 가이드를 제공합니다.
여러 플랫폼과 통합하여 문자를 발송할 수 있습니다.

  • API 를 연동하기 전, 관리툴에서  발송 IP,
    발신번호등록, API Key를 먼저 설정하세요.

    관리툴(sms.gabia.com) 설정 단계

    1 .발송 IP 등록기본 설정 -> API 발송 IP 설정

    2. 발신 번호 등록환경 설정 -> 발신 번호

    3. API Key 발급 관리자 -> 서비스 정보 -> 관리 중인 서비스 -> API 인증키 정보

  • 가비아 문자 서비스는
    REST API 연동 방식을 지원합니다.

    REST API

    단문, 장문, 포토, 국제 문자(단문) 발송 가능
    제공 언어: PHP, JAVA, PYTHON,
    NODE, RUBY, GO, cURL

사용자 인증

SMS ID와 API Key로 토큰을 발행해 사용자를 인증합니다.

  • 사용자 인증 단계에서만, Authroization에 'API_ KEY' 값을 넣어주세요.

POSThttps://sms.gabia.com/oauth/token

  • HEADERS

    Content-Type application/x-www-form-urlencoded
    Authorization Basic base64encode(SMS_ID:API_KEY)
    (예) Basic c1hY3JvY2sZDAwNzA2YzJlMTdjZjlkMz1234hlM2U5YjQ=
  • BODY

    grant_type client_credentials
  • RESPONSE

    성공케이스

    {

    access_token": "your_access_token",
    "refresh_token": "your_refresh_token",
    "expires_in": 3600,"scope": "basic",
    "create_on": "2022-01-01 00:00:01","is_expires": "N",
    "token_type": "basic",
    "code": "basic"

    }

    실패케이스 {"message": "SMS ID나 API KEY가 잘못되었습니다."}
    {"message": "unsupported_grant_type (grant_type 값을 확인해주세요.)"}

    * Authorization 값 확인이 안 되는 경우, {"message": "client_id empty"} 또는 {"message": "client_secret empty"}가 출력됩니다.
    sms_id:api_key 형태로 base64인코딩 규격을 맞춰주세요.

          
            <?php

              $curl = curl_init();

              curl_setopt_array($curl, array(
                CURLOPT_URL => "https://sms.gabia.com/oauth/token",
                CURLOPT_RETURNTRANSFER => true,
                CURLOPT_ENCODING => "",
                CURLOPT_MAXREDIRS => 10,
                CURLOPT_TIMEOUT => 0,
                CURLOPT_FOLLOWLOCATION => false,
                CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
                CURLOPT_CUSTOMREQUEST => "POST",
                CURLOPT_POSTFIELDS => "grant_type=client_credentials",
                CURLOPT_HTTPHEADER => array(
                  "Content-Type: application/x-www-form-urlencoded",
                  "Authorization: Basic c1hY3JvY2sZDAwNzA2YzJlMTdjZjlkMz1234hlM2U5YjQ="
                ),
              ));

              $response = curl_exec($curl);
              $err = curl_error($curl);

              curl_close($curl);

              if ($err) {
                echo "cURL Error #:" . $err;
              } else {
                echo $response;
              }
            ?>
          
        
          
            import com.google.gson.Gson;
            import java.io.IOException;
            import java.nio.charset.StandardCharsets;
            import java.util.Base64;
            import java.util.HashMap;
            import java.util.Objects;
            import okhttp3.MultipartBody;
            import okhttp3.OkHttpClient;
            import okhttp3.Request;
            import okhttp3.RequestBody;
            import okhttp3.Response;

            // 외부 라이브러리 다운로드가 필요합니다. (gradle 기준)
            // implementation 'com.squareup.okhttp3:okhttp:4.9.3'
            https://mvnrepository.com/artifact/com.squareup.okhttp/okhttp
            // implementation 'com.google.code.gson:gson:2.9.0' https://github.com/google/gson

            public class userAuth {
              public static final String SMS_OAUTH_TOKEN_URL = "https://sms.gabia.com/oauth/token"; // ACCESS
              TOKEN 발급 API URL 입니다.

              public static void main(String[] args) throws IOException {
                String smsId = "YOUR_SMS_ID"; // SMS ID 를 입력해 주세요.
                String apiKey = "YOUR_API_KEY"; // SMS 관리툴에서 발급받은 API KEY 를 입력해 주세요.
                String authValue =
                Base64.getEncoder().encodeToString(String.format("%s:%s", smsId,
                apiKey).getBytes(StandardCharsets.UTF_8)); // Authorization Header 에 입력할 값입니다.

                // 사용자 인증 API 를 호출합니다.
                OkHttpClient client = new OkHttpClient();

                RequestBody requestBody = new MultipartBody.Builder().setType(MultipartBody.FORM)
                .addFormDataPart("grant_type", "client_credentials")
                .build();

                Request request = new Request.Builder()
                .url(SMS_OAUTH_TOKEN_URL)
                .post(requestBody)
                .addHeader("Content-Type", "application/x-www-form-urlencoded")
                .addHeader("Authorization", "Basic " + authValue)
                .addHeader("cache-control", "no-cache")
                .build();

                // Response 를 key, value 로 확인하실 수 있습니다.
                Response response = client.newCall(request).execute();
                HashMap<String, String> result = new
                Gson().fromJson(Objects.requireNonNull(response.body()).string(), HashMap.class);
                for(String key : result.keySet()) {
                  System.out.printf("%s: %s%n", key, result.get(key));
                }
              }
            }
          
        
          
            import requests
            url = 'https://sms.gabia.com/oauth/token'
            payload = 'grant_type=client_credentials'
            headers = {
              'Content-Type': 'application/x-www-form-urlencoded',
              'Authorization': 'Basic c1hY3JvY2sZDAwNzA2YzJlMTdjZjlkMz1234hlM2U5YjQ='
            }
            response = requests.request('POST', url, headers = headers, data = payload, allow_redirects=False,
            timeout=undefined)
            print(response.text)
          
        
          
          // Node.js에서 fetch 사용: Node.js 18 버전 이상에서는 fetch가 기본적으로 내장되어 있습니다. 
          // 하지만 그 이하 버전에서는 node-fetch 패키지를 설치해야 합니다.
          // npm install node-fetch
          // 그런 다음 코드 상단에 다음과 같이 fetch와 Headers를 가져와야 합니다.
          
          // const fetch = require('node-fetch');
          // const { Headers } = require('node-fetch');
          const myHeaders = new Headers();
          myHeaders.append("Content-Type", "application/x-www-form-urlencoded");
          myHeaders.append("Authorization", "Basic YOUR_TOKEN_HERE"); // 실제 토큰으로 대체하세요.

          const urlencoded = new URLSearchParams();
          urlencoded.append("grant_type", "client_credentials");

          const requestOptions = {
            method: 'POST',
            headers: myHeaders,
            body: urlencoded,
            redirect: 'follow'
          };

          fetch("https://sms.gabia.com/oauth/token", requestOptions)
            .then(response => response.text())
            .then(result => console.log(result))
            .catch(error => console.error('error', error));
            
        
          
            require "uri"
            require "net/http"

            url = URI("https://sms.gabia.com/oauth/token")

            https = Net::HTTP.new(url.host, url.port)
            https.use_ssl = true

            request = Net::HTTP::Post.new(url)
            request["Content-Type"] = "application/x-www-form-urlencoded"
            request["Authorization"] = "Basic c1hY3JvY2sZDAwNzA2YzJlMTdjZjlkMz1234hlM2U5YjQ="
            request.body = "grant_type=client_credentials"

            response = https.request(request)
            puts response.read_body
          
        
          
            curl --location --request POST
            "https://sms.gabia.com/oauth/token" \
            --header "Content-Type: application/x-www-form-urlencoded" \
            --header "Authorization: Basic c1hY3JvY2sZDAwNzA2YzJlMTdjZjlkMz1234hlM2U5YjQ=" \
            --data "grant_type=client_credentials"
          
        
          
            package main

            import (
              "fmt"
              "strings"
              "os"
              "path/filepath"
              "net/http"
              "io/ioutil"
            )

            func main() {

              url := "https://sms.gabia.com/oauth/token"
              method := "POST"

              payload := strings.NewReader("grant_type=client_credentials")

              client := &http.Client {
                CheckRedirect: func(req *http.Request, via []*http.Request) error {
                  return http.ErrUseLastResponse
                },
              }
              req, err := http.NewRequest(method, url, payload)

              if err != nil {
                fmt.Println(err)
              }
              req.Header.Add("Content-Type", "application/x-www-form-urlencoded")
              req.Header.Add("Authorization", "Basic c1hY3JvY2sZDAwNzA2YzJlMTdjZjlkMz1234hlM2U5YjQ=")

              res, err := client.Do(req)
              defer res.Body.Close()
              body, err := ioutil.ReadAll(res.Body)

              fmt.Println(string(body))
            }