{"id":25524829,"url":"https://github.com/minchao/every8d-php","last_synced_at":"2025-04-11T03:42:44.478Z","repository":{"id":44870828,"uuid":"115808812","full_name":"minchao/every8d-php","owner":"minchao","description":"EVERY8D 簡訊 PHP SDK","archived":false,"fork":false,"pushed_at":"2022-07-28T12:48:39.000Z","size":64,"stargazers_count":12,"open_issues_count":0,"forks_count":5,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-25T01:43:38.309Z","etag":null,"topics":["every8d","php","php7","sms","sms-sdk","taiwan-sms"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","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-12-30T16:27:23.000Z","updated_at":"2024-03-02T12:42:10.000Z","dependencies_parsed_at":"2022-08-27T12:41:26.205Z","dependency_job_id":null,"html_url":"https://github.com/minchao/every8d-php","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/minchao%2Fevery8d-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/minchao%2Fevery8d-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/minchao%2Fevery8d-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/minchao%2Fevery8d-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/minchao","download_url":"https://codeload.github.com/minchao/every8d-php/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247959797,"owners_count":21024842,"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":["every8d","php","php7","sms","sms-sdk","taiwan-sms"],"created_at":"2025-02-19T20:16:26.460Z","updated_at":"2025-04-11T03:42:44.457Z","avatar_url":"https://github.com/minchao.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# every8d-php\n\n[![Build Status](https://travis-ci.org/minchao/every8d-php.svg?branch=master)](https://travis-ci.org/minchao/every8d-php)\n[![Latest Stable Version](https://poser.pugx.org/minchao/every8d-php/v/stable)](https://packagist.org/packages/minchao/every8d-php)\n[![Latest Unstable Version](https://poser.pugx.org/minchao/every8d-php/v/unstable)](https://packagist.org/packages/minchao/every8d-php)\n[![composer.lock](https://poser.pugx.org/minchao/every8d-php/composerlock)](https://packagist.org/packages/minchao/every8d-php)\n\nevery8d-php 是 [EVERY8D](http://global.every8d.com.tw/) SMS HTTP API 2.1 的非官方 PHP Client SDK，使用前請先確認您已申請 EVERY8D 簡訊帳號。若您想在 Laravel 下使用，請參考 [every8d-laravel](https://github.com/minchao/every8d-laravel) 提供的 Service provider。\n\n支援的 APIs：\n\n- 取得帳戶餘額\n  - [x] API21/HTTP/getCredit.ashx\n- SMS\n  - [x] API21/HTTP/sendSMS.ashx\n  - [x] API21/HTTP/getDeliveryStatus.ashx\n  - [x] API21/HTTP/eraseBooking.ashx\n- MMS\n  - [x] API21/HTTP/MMS/sendMMS.ashx\n  - [x] API21/HTTP/MMS/getDeliveryStatus.ashx\n  - [x] API21/HTTP/MMS/eraseBooking.ashx\n\n## 執行環境\n\n* PHP \u003e= 7.0\n* [Guzzle requirements](http://guzzle.readthedocs.io/en/latest/overview.html#requirements)\n\n## 安裝\n\n推薦使用 [Composer](https://getcomposer.org/) 安裝 every8d-php SDK，請在您的專案下執行：\n\n```console\n$ composer require minchao/every8d-php\n```\n\n## 使用\n\n初始化 Client，設定 EVERY8D 帳號與密碼。\n\n```php\n\u003c?php\n\nrequire_once __DIR__ . '/vendor/autoload.php';\n\n$client = new \\Every8d\\Client(['username' =\u003e 'USERNAME', 'password' =\u003e 'PASSWORD']);\n```\n\n### 範例\n\n#### 發送 SMS\n\nExample:\n\n```php\ntry {\n    $sms = new \\Every8d\\Message\\SMS('+886987654321', 'Hello, 世界');\n    $result = $client-\u003esendSMS($sms);\n} catch (\\Exception $e) {\n    // 處理異常\n}\n```\n\nResult:\n\n```php\n[\n    'Credit' =\u003e 79.0,\n    'Sent' =\u003e 1,\n    'Cost' =\u003e 1.0,\n    'Unsent' =\u003e 0,\n    'BatchID' =\u003e '00000000-0000-0000-0000-000000000000',\n]\n```\n\n#### 查詢 SMS 發送狀態\n\nExample:\n\n```php\ntry {\n    $batchId = '00000000-0000-0000-0000-000000000000';\n    $result = $client-\u003egetDeliveryStatusBySMS($batchId);\n} catch (\\Exception $e) {\n    // 處理異常\n}\n```\n\nResult:\n\n```php\n[\n    'Count' =\u003e 1,\n    'Records' =\u003e [\n        'Name' =\u003e '',\n        'Mobile' =\u003e '+886987654321',\n        'SendTime' =\u003e '2018/01/01 00:00:00',\n        'Cost' =\u003e 1.0,\n        'Status' =\u003e 0,\n    ],\n]\n```\n\n#### 查詢餘額\n\nExample:\n\n```php\ntry {\n    $client-\u003egetCredit();\n} catch (\\Exception $e) {\n    // 處理異常\n}\n```\n\nResult:\n\n```php\n79.0\n```\n\n### 使用 Webhook 接收簡訊發送回報\n\n若您的帳號有設定 callback 回報網址，簡訊伺服器就會在簡訊發送後以 HTTP GET 方法通知回報網址。您可參考 [webhook](./webhook/index.php) 中的範例來接收簡訊發送回報。\n\n啟動 Webhook：\n\n使用 [PHP Built-in web server](http://php.net/manual/en/features.commandline.webserver.php) 快速啟動一個 Webhook 服務。\n\n```console\n$ php -S 127.0.0.1:80 -t webhook webhook/index.php\nPHP 7.0.26 Development Server started at Mon Jan  1 12:00:00 2018\nListening on http://127.0.0.1:80\nDocument root is /srv/www/every8d-php/webhook\nPress Ctrl-C to quit.\n```\n\n\u003e 注意：PHP Built-in web server 僅供開發測試使用，請不要使用在正式環境或公用網路上\n\n回報範例：\n\n這是一個發送 SMS 後，接收到的回報範例。\n\n```\n[Mon Jan  1 12:01:00 2018] http://your-webhook.com/callback?BatchID=00000000-0000-0000-0000-000000000000\u0026RM=%2b886987654321\u0026RT=20180101120002\u0026STATUS=100\u0026SM=Hello%2c+%e4%b8%96%e7%95%8c\u0026CustID=CUSTID\u0026UserNo=000000\u0026ST=20180101120001\u0026MR=1\u0026SUBJECT=\u0026NAME=NAME\u0026USERID=USERNAME\u0026SOURCE=\u0026CHARGE=0\narray:14 [\n  \"BatchID\" =\u003e \"00000000-0000-0000-0000-000000000000\"\n  \"RM\" =\u003e \"+886987654321\"\n  \"RT\" =\u003e \"20180101120002\"\n  \"STATUS\" =\u003e \"100\"\n  \"SM\" =\u003e \"Hello, 世界\"\n  \"CustID\" =\u003e \"CUSTID\"\n  \"UserNo\" =\u003e \"000000\"\n  \"ST\" =\u003e \"20180101120001\"\n  \"MR\" =\u003e \"1\"\n  \"SUBJECT\" =\u003e \"\"\n  \"NAME\" =\u003e \"NAME\"\n  \"USERID\" =\u003e \"USERNAME\"\n  \"SOURCE\" =\u003e \"\"\n  \"CHARGE\" =\u003e \"0\"\n]\n```\n\n## 開發\n\n### 開發工具\n\n本專案提供 Command Line Developer Tools，供您在開發時作為測試工具使用。\n\n指令：\n\n```console\n$ bin/every8d\nDeveloper Tools 0.0.1\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  EVERY8D Username\n  -p, --password=PASSWORD  EVERY8D Password\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  cancel           取消預約簡訊\n  credit           餘額查詢\n  delivery-status  發送狀態查詢\n  help             Displays help for a command\n  list             Lists commands\n  send             發送 SMS\n```\n\n發送 SMS 範例如下：\n\n```console\n$ bin/every8d send -u USERNAME -p PASSWORD +886987654321 'Hello, World'\narray:5 [\n  \"Credit\" =\u003e 79.0\n  \"Sent\" =\u003e 1\n  \"Cost\" =\u003e 1.0\n  \"Unsent\" =\u003e 0\n  \"BatchID\" =\u003e \"00000000-0000-0000-0000-000000000000\"\n]\n```\n\n### 測試\n\n執行 PHPCS 與 Unit tests。\n\n```console\n$ composer run check\n```\n\n產生測試覆蓋率報告。\n\n```console\n$ composer run coverage-html\n```\n\n## License\n\nThis library is distributed under the BSD-style license found in the [LICENSE](./LICENSE) file.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fminchao%2Fevery8d-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fminchao%2Fevery8d-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fminchao%2Fevery8d-php/lists"}