{"id":25525266,"url":"https://github.com/minchao/mitake-php","last_synced_at":"2025-04-11T03:42:52.757Z","repository":{"id":25546604,"uuid":"104492093","full_name":"minchao/mitake-php","owner":"minchao","description":"三竹簡訊 PHP SDK","archived":false,"fork":false,"pushed_at":"2022-06-09T08:07:26.000Z","size":92,"stargazers_count":33,"open_issues_count":3,"forks_count":6,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-25T01:43:44.598Z","etag":null,"topics":["mitake","php","sms","sms-sdk","taiwan-sms"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/minchao.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-09-22T15:48:22.000Z","updated_at":"2025-02-26T16:31:25.000Z","dependencies_parsed_at":"2022-08-24T05:30:31.773Z","dependency_job_id":null,"html_url":"https://github.com/minchao/mitake-php","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/minchao%2Fmitake-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/minchao%2Fmitake-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/minchao%2Fmitake-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/minchao%2Fmitake-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/minchao","download_url":"https://codeload.github.com/minchao/mitake-php/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248021118,"owners_count":21034581,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["mitake","php","sms","sms-sdk","taiwan-sms"],"created_at":"2025-02-19T20:18:59.954Z","updated_at":"2025-04-11T03:42:52.741Z","avatar_url":"https://github.com/minchao.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# mitake-php\n\n[![Continuous Integration](https://github.com/minchao/mitake-php/actions/workflows/continuous-integration.yml/badge.svg?branch=master)](https://github.com/minchao/mitake-php/actions/workflows/continuous-integration.yml)\n[![Codacy Badge](https://api.codacy.com/project/badge/Grade/1b7b6ee48e884e6aa48d76605871ba83)](https://www.codacy.com/app/minchao/mitake-php?utm_source=github.com\u0026amp;utm_medium=referral\u0026amp;utm_content=minchao/mitake-php\u0026amp;utm_campaign=Badge_Grade)\n[![codecov](https://codecov.io/gh/minchao/mitake-php/branch/master/graph/badge.svg)](https://codecov.io/gh/minchao/mitake-php)\n[![Latest Stable Version](https://poser.pugx.org/minchao/mitake-php/v/stable)](https://packagist.org/packages/minchao/mitake-php)\n[![Latest Unstable Version](https://poser.pugx.org/minchao/mitake-php/v/unstable)](https://packagist.org/packages/minchao/mitake-php)\n[![composer.lock](https://poser.pugx.org/minchao/mitake-php/composerlock)](https://packagist.org/packages/minchao/mitake-php)\n\nmitake-php 是[三竹簡訊](https://sms.mitake.com.tw/) SMS HTTP API 的非官方 PHP Client SDK（僅支援台灣行動電話號碼），使用這個 SDK 前，\n請確認您已申請三竹簡訊 HTTP Function Call 功能，若您想在 Laravel 下使用，請參考 [mitake-laravel](https://github.com/minchao/mitake-laravel) 提供的 Service provider\n\n## 執行環境\n\n* PHP \u003e= 5.6\n* [Guzzle requirements](http://guzzle.readthedocs.io/en/latest/overview.html#requirements)\n\n## 安裝\n\n推薦使用 [Composer](https://getcomposer.org/) 安裝 mitake-php\n\n```\n$ composer require minchao/mitake-php\n```\n\n## 使用\n\n### Mitake client\n\n實例化 Mitake client，USERNAME 與 PASSWORD 請分別填入您申請的三竹簡訊帳號與密碼\n\n```php\n\u003c?php\n\nrequire_once __DIR__ . '/vendor/autoload.php';\n\n$client = new \\Mitake\\Client('USERNAME', 'PASSWORD');\n```\n\n## 範例\n\n呼叫 Mitake API\n\n### 查詢帳戶餘額\n\n查詢目前的帳戶剩餘點數\n\n```php\n$resp = $client-\u003equeryAccountPoint();\n```\n\n### 發送單筆簡訊\n\n發送簡訊前，請先透過 Message 類別建立簡訊內容，再呼叫 API 的 send() 方法發送\n\n```php\n$message = (new \\Mitake\\Message\\Message())\n    -\u003esetDstaddr('0987654321')\n    -\u003esetSmbody('Hello, 世界');\n$resp = $client-\u003esend($message);\n```\n\n### 發送多筆簡訊\n\n若要一次發送多筆簡訊，請先建立欲發送的 **Message objects** 陣列，再呼叫 API 的 sendBatch() 方法發送\n\n```php\n$resp = $client-\u003esendBatch([$message1, $message2]);\n```\n\n### 發送單筆長簡訊\n\n發送長簡訊前，請先透過 LongMessage 類別建立簡訊內容，再呼叫 API 的 sendLongMessage() 方法發送\n\n```php\n$message = (new \\Mitake\\Message\\LongMessage())\n    -\u003esetDstaddr('0987654321')\n    -\u003esetSmbody('Hello, 世界');\n$resp = $client-\u003esendLongMessage($message);\n```\n\n### 發送多筆長簡訊\n\n若要一次發送多筆長簡訊，請先建立欲發送的 **LongMessage objects** 陣列，再呼叫 API 的 sendLongMessageBatch() 方法發送\n\n```php\n$resp = $client-\u003esendLongMessageBatch([$message1, $message2]);\n```\n\n### 查詢簡訊發送狀態\n\n查詢時請帶入簡訊發送後返回的 msgid\n\n```php\n$resp = $client-\u003equeryMessageStatus(['MESSAGE_ID1', 'MESSAGE_ID2]);\n```\n\n### 取消預約發送簡訊\n\n取消時請帶入簡訊 msgid\n\n```php\n$resp = $client-\u003ecancelMessageStatus(['MESSAGE_ID1', 'MESSAGE_ID2]);\n```\n\n### 使用 webhook 接收傳送狀態\n\n發送簡訊時若有設定 response 網址，簡訊伺服器就會在發送狀態更新時以 HTTP GET 方法通知指定的 response 網址，\n您可參考 [webhook](webhook/index.php) 中的範例來接收簡訊傳送狀態\n\n簡訊設定 response 網址：\n\n```php\n$message-\u003esetResponse('https://your.domain.name/callback');\n```\n\n建立 webhook：\n\n```php\n$app = new Slim\\App();\n\n$app-\u003eget('/callback', function (Request $request, Response $response, $args) {\n    $params = parse_query($request-\u003egetUri()-\u003egetQuery());\n    if (isset($params['msgid'])) {\n        $receipt = new Receipt();\n        $receipt-\u003esetMsgid($params['msgid']);\n        // ...\n    }\n}\n```\n\n## 開發\n\n### 開發工具\n\n本專案提供 Command Line Developer Tools，供您在開發時作為測試工具使用\n\n指令：\n\n```\n$ bin/mitake\nDeveloper Tools\n\nUsage:\n  command [options] [arguments]\n\nOptions:\n  -h, --help                       Display this help message\n  -q, --quiet                      Do not output any message\n  -V, --version                    Display this application version\n      --ansi                       Force ANSI output\n      --no-ansi                    Disable ANSI output\n  -n, --no-interaction             Do not ask any interactive question\n  -u, --username[=USERNAME]        Mitake Username\n  -p, --password[=PASSWORD]        Mitake Password\n  -c, --credentials[=CREDENTIALS]  Mitake Credentials\n  -v|vv|vvv, --verbose             Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug\n\nAvailable commands:\n  balance  Retrieve your account balance\n  help     Displays help for a command\n  list     Lists commands\n  send     Send an message\n  status   Fetch the status of specific messages\n```\n\n使用範例如下：\n\n```\n$ bin/mitake send -u USERNAME -p PASSWORD -d 0987654321 -b 'Hello, 世界'\n{\n    \"results\": [\n        {\n            \"msgid\": \"1234567890\",\n            \"statuscode\": \"1\"\n        }\n    ],\n    \"accountPoint\": \"999\"\n}\n```\n\n### 使用 Docker Compose 啟動 webhook 服務\n\n請設定環境變數 VIRTUAL_HOST、LETSENCRYPT_HOST 與 LETSENCRYPT_EMAIL，Docker Compose 會在本機的 443 Port 上啟動 webhook 服務，\n並自動透過 Let's Encrypt 建立 SSL 憑證\n\nCommand:\n\n```\n$ VIRTUAL_HOST=your.domain.name \\\n  LETSENCRYPT_HOST=your.domain.name \\\n  LETSENCRYPT_EMAIL=username@mail.com \\\n  docker-compose up\n```\n\nLogs:\n\n```\nwebhook | 172.18.0.3 - - [01/Oct/2017:05:17:34 +0000] \"GET /callback?msgid=1234567890\u0026dstaddr=0987654321\u0026dlvtime=20171001112328\u0026donetime=20171001112345\u0026statusstr=DELIVRD\u0026statuscode=0\u0026StatusFlag=4 HTTP/2.0\" 200 156 \"-\" \"Mozilla/5.0\"\n```\n\n### 執行測試\n\n執行 phpcs 與 phpunit 測試\n\n```\n$ composer run check\n```\n\n## FAQ\n\nQ：遇到 `PHP Fatal error: Uncaught GuzzleHttp\\Exception\\ConnectException: cURL error 35`\n\nA：這是因為 OpenSSL 已不支援 TLS 1.1 以下版本，建議使用[長簡訊方法](https://github.com/minchao/mitake-php#%E7%99%BC%E9%80%81%E5%96%AE%E7%AD%86%E9%95%B7%E7%B0%A1%E8%A8%8A)來傳送簡訊，請參考 Issue [#4](https://github.com/minchao/mitake-php/issues/4) 的說明。\n\n**注意：使用 HTTP 或已棄用的 TLS 協議來傳送簡訊，會將傳輸資料暴露外洩的風險之中。**\n\n## License\n\nSee the [LICENSE](LICENSE) file for license rights and limitations (MIT).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fminchao%2Fmitake-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fminchao%2Fmitake-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fminchao%2Fmitake-php/lists"}