Skip to content

Commit 8126a0c

Browse files
Merge pull request #25 from Palbahngmiyine/master
SOLAPI PHP SDK 5.1.2
2 parents 4be7a94 + cf20624 commit 8126a0c

4 files changed

Lines changed: 51 additions & 3 deletions

File tree

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "solapi/sdk",
33
"description": "SOLAPI SDK for PHP",
4-
"version": "5.1.0",
4+
"version": "5.1.2",
55
"type": "library",
66
"license": "MIT",
77
"autoload": {

composer.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?php
2+
3+
require_once dirname(__DIR__) . '/vendor/autoload.php';
4+
5+
use GuzzleHttp\Client;
6+
use Nurigo\Solapi\Exceptions\MessageNotReceivedException;
7+
use Nurigo\Solapi\Models\Message;
8+
use Nurigo\Solapi\Services\SolapiMessageService;
9+
10+
/**
11+
* 커스텀 PSR-18 HTTP 클라이언트를 이용한 SMS 발송 예제
12+
*
13+
* SolapiMessageService 생성자의 3번째 인자로 PSR-18(Psr\Http\Client\ClientInterface) 호환 HTTP 클라이언트를 주입할 수 있습니다.
14+
* 이 예제에서는 Guzzle HTTP 클라이언트를 사용합니다.
15+
*
16+
* 사전 설치가 필요합니다:
17+
* composer require guzzlehttp/guzzle
18+
*
19+
* Guzzle 외에도 PSR-18을 구현한 다른 HTTP 클라이언트를 사용할 수 있습니다:
20+
* - Symfony HttpClient (symfony/http-client + symfony/psr-http-message-bridge)
21+
* - PHP-HTTP Curl Client (php-http/curl-client)
22+
*/
23+
try {
24+
// Guzzle 클라이언트 생성 (필요에 따라 옵션을 설정할 수 있습니다)
25+
$httpClient = new Client([
26+
'timeout' => 10,
27+
'connect_timeout' => 5,
28+
// 'proxy' => 'http://proxy.example.com:8080',
29+
// 'verify' => '/path/to/cacert.pem',
30+
]);
31+
32+
// SolapiMessageService 생성 시 3번째 인자로 커스텀 HTTP 클라이언트를 전달합니다
33+
$messageService = new SolapiMessageService("ENTER_YOUR_API_KEY", "ENTER_YOUR_API_SECRET", $httpClient);
34+
35+
$message = new Message();
36+
$message->setTo("수신번호")
37+
->setFrom("계정에서 등록한 발신번호 입력")
38+
->setText("한글 45자, 영자 90자 이하 입력되면 자동으로 SMS타입의 메시지가 발송됩니다.");
39+
40+
$result = $messageService->send($message);
41+
print_r($result);
42+
} catch (MessageNotReceivedException $exception) {
43+
print_r($exception->getFailedMessageList());
44+
print_r("----");
45+
print_r($exception->getMessage());
46+
} catch (Exception $exception) {
47+
print_r($exception->getMessage());
48+
}

src/Models/Request/DefaultAgent.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class DefaultAgent
1616

1717
public function __construct()
1818
{
19-
$this->sdkVersion = 'php/5.1.1';
19+
$this->sdkVersion = 'php/5.1.2';
2020
$this->osPlatform = PHP_OS . " | " . phpversion();
2121
}
2222
}

0 commit comments

Comments
 (0)