{"id":20732371,"url":"https://github.com/jpush/jsms-api-php-client","last_synced_at":"2025-04-23T22:08:20.182Z","repository":{"id":56998978,"uuid":"66351812","full_name":"jpush/jsms-api-php-client","owner":"jpush","description":"JiGuang's officially supported PHP client library for accessing JSMS APIs. 极光官方支持的 JSMS PHP 版本服务器端 SDK。","archived":false,"fork":false,"pushed_at":"2019-04-25T09:13:57.000Z","size":26,"stargazers_count":8,"open_issues_count":0,"forks_count":4,"subscribers_count":16,"default_branch":"master","last_synced_at":"2025-04-23T22:07:17.216Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://docs.jiguang.cn","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/jpush.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":"2016-08-23T09:11:01.000Z","updated_at":"2021-06-18T02:19:09.000Z","dependencies_parsed_at":"2022-08-21T14:50:25.076Z","dependency_job_id":null,"html_url":"https://github.com/jpush/jsms-api-php-client","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jpush%2Fjsms-api-php-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jpush%2Fjsms-api-php-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jpush%2Fjsms-api-php-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jpush%2Fjsms-api-php-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jpush","download_url":"https://codeload.github.com/jpush/jsms-api-php-client/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250522299,"owners_count":21444511,"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":[],"created_at":"2024-11-17T05:19:07.332Z","updated_at":"2025-04-23T22:08:20.039Z","avatar_url":"https://github.com/jpush.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# JSMS API PHP CLIENT\n\n这是短信 API 的 PHP 版本封装开发包，是由极光官方提供的，一般支持最新的 API 功能。\n\n对应的 API 文档：https://docs.jiguang.cn/jsms/server/rest_api_summary/\n\n\u003e 支持的 PHP 版本: 5.3.3 ～ 5.6.x, 7.0.x\n\u003e 须启用 cURL 扩展\n\n## Installation\n\n- 在项目中的 `composer.json` 文件中添加 JSMS 依赖：\n\n```json\n\"require\": {\n    \"jiguang/jsms\": \"~1.0\"\n}\n```\n\n- 执行 `$ php composer.phar install` 或 `$ composer install` 进行安装。\n\n## Usage\n\n#### 初始化\n\n```php\nuse JiGuang\\JSMS as JSMS;\n...\n...\n\n    $client = new JSMS($app_key, $master_secret);\n\n...\n```\n\nOR\n\n```php\n$client = new \\JiGuang\\JSMS($app_key, $master_secret);\n```\n\n#### 证书问题\n\n```php\n// 禁用 SSL 证书的验证，\n$client = new JSMS($app_key, $master_secret, [ 'disable_ssl' =\u003e true ]);\n```\n\n**希望开发者在了解相关风险的前提下如此处理 SSL 证书问题。**\n\n#### 发送验证码\n\n```php\n$client-\u003esendCode($phone, $temp_id, $sign = null);\n```\n\n**参数说明:**\n\n\u003e $phone: 接收验证码的手机号码\n\n\u003e $temp_id: 模板ID\n\n\u003e $sign_id: 签名ID，null 表示使用应用默认签名\n\n#### 发送语音短信验证码\n\n```php\n$client-\u003esendVoiceCode($phone, $options = []);\n```\n\n**参数说明:**\n\n\u003e $phone: 接收验证码的手机号码\n\n\u003e $options: 可选选项数组，接受 3 个键 `ttl`，`code`，`voice_lang` 中的一个或多个。\n\n- ttl: 超时时间，默认为 60 秒\n- code: 语音验证码的值，验证码仅支持 4-8 个数字\n- voice_lang: 播报语言选择，0：中文播报，1：英文播报，2：中英混合播报\n\n#### 验证\n\n```php\n$client-\u003echeckCode($msg_id, $code);\n```\n\n**参数说明:**\n\n\u003e $msg_id: 发送验证码 sendCode 函数返回的数组中的 msg_id 键对应的值\n\n\u003e $code: 手机接收到的验证码\n\n#### 发送模板短信\n\n```php\n$client-\u003esendMessage($mobile, $temp_id, array $temp_para = [], $time = null, $sign_id = null);\n```\n\n**参数说明:**\n\n\u003e $phone: 接收验证码的手机号码\n\n\u003e $temp_id: 模板 ID\n\n\u003e $temp_para: 模板参数,需要替换的参数名和 value 的键值对,仅接受数组类型的值\n\n\u003e $time: 定时短信发送时间，格式为 yyyy-MM-dd HH:mm:ss，默认为 `null` 表示立即发送\n\n\u003e $sign_id: 签名ID，null 表示使用应用默认签名\n\n#### 发送批量模板短信\n\n```php\n$client-\u003esendBatchMessage($temp_id, array $recipients，$time = null, sign_id = null, $tag = null);\n```\n\n**参数说明:**\n\n\u003e $temp_id: 模板 ID\n\n\u003e $recipients: 接收者列表，接受一个以 mobile 为键，对应其 temp_para 为值的关联数组\n\n\u003e $time: 定时短信发送时间，格式为 yyyy-MM-dd HH:mm:ss，默认为 `null` 表示立即发送\n\n\u003e $sign_id: 签名ID，null 表示使用应用默认签名\n\n\u003e $tag: 标签，仅用作标示该短信的别名，不在短信中展示，最多不超过 10 个字\n\n#### 查询定时模板短信\n\n```php\n$client-\u003eshowSchedule($scheduleId);\n```\n\n#### 删除定时模板短信\n\n```php\n$client-\u003edeleteSchedule($scheduleId);\n```\n\n#### 应用余量查询\n\n```php\n$client-\u003egetAppBalance();\n```\n\n#### 调用返回码说明\n\nhttp://docs.jiguang.cn/server/rest_api_jsms/#_12\n\n## Examples\n\n在下载的中的 [examples](https://github.com/jpush/jsms-api-php-client/tree/master/examples) 文件夹有简单示例代码, 开发者可以参考其中的样例快速了解该库的使用方法。\n\n\u003e **注：所下载的样例代码不可马上使用，需要在相应文件中填入相关的必要参数，不然示例运行会失败**\n\n#### 简单使用方法\n\n\u003e 假定当前目录为 JSMS 源码所在的根目录\n\n- 编辑 `examples/config.php` 文件，填写信息\n\n```php\n$appKey = 'xxxx';\n$masterSecret = 'xxxx';\n$phone = 'xxxxxxxxxxx';\n```\n\n- 运行示例 `$ php examples/send_example.php`\n\n- 获取 `msg_id` 和 `code`\n\n- 编辑 `examples/check_example.php` 文件，填写信息\n\n```php\n$msg_id = 'xxxx';\n$code = 'xxxxxx';\n```\n\n- 运行示例 `$ php examples/check_example.php`\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/jpush/jsms-api-php-client.\n\n## License\n\nThe library is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjpush%2Fjsms-api-php-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjpush%2Fjsms-api-php-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjpush%2Fjsms-api-php-client/lists"}