{"id":18704769,"url":"https://github.com/lancewan/laravel5-cloud","last_synced_at":"2025-04-12T09:33:17.007Z","repository":{"id":57011027,"uuid":"55667325","full_name":"lanceWan/laravel5-cloud","owner":"lanceWan","description":"荣联云通讯扩展包，双向回拨电话，发送短信验证码，语音验证码功能","archived":false,"fork":false,"pushed_at":"2016-05-13T04:03:22.000Z","size":34,"stargazers_count":11,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-09-14T16:56:04.520Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lanceWan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-04-07T05:52:17.000Z","updated_at":"2023-10-31T11:21:11.000Z","dependencies_parsed_at":"2022-08-21T13:40:46.036Z","dependency_job_id":null,"html_url":"https://github.com/lanceWan/laravel5-cloud","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lanceWan%2Flaravel5-cloud","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lanceWan%2Flaravel5-cloud/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lanceWan%2Flaravel5-cloud/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lanceWan%2Flaravel5-cloud/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lanceWan","download_url":"https://codeload.github.com/lanceWan/laravel5-cloud/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223510320,"owners_count":17157306,"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-07T12:08:17.799Z","updated_at":"2024-11-07T12:08:18.582Z","avatar_url":"https://github.com/lanceWan.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# laravel5-cloud\n\n[云通讯官方API文档](http://docs.yuntongxun.com/index.php/%E9%A6%96%E9%A1%B5)\n\nPackagist:[https://packagist.org/packages/lancewan/laravel5-cloud](https://packagist.org/packages/lancewan/laravel5-cloud)\n\n## 快速安装\n\n通过`composer`来安装\n\n```php\ncomposer require lancewan/laravel5-cloud\n```\n\n或者加入下面代码到 `composer.json` 文件,并执行`composer install` **Or** `composer update`:\n\n```php\n\"lancewan/laravel5-cloud\": \"^1.0\"\n```\n扩展包加载完成后,在 `config/app.php` 的文件中加入以下代码:\n\n### Service Provider\n```php\nLance\\Cloud\\CloudServiceProvider::class,\n```\n\n### Facade\n```php\n'Cloud'\t=\u003e Lance\\Cloud\\Facades\\Cloud::class,\n```\n\n最后执行 `php artisan vendor:publish` ,在`config`文件夹下将会生成一个`cloud.php`的配置文件.\n\nAnd that's it! \n\n## cloud.php 配置文件\n`cloud.php`是云通讯的配置文件,主要配置信息如下:\n\n```php\n\u003c?php\nreturn [\n\t// AccountSid 主帐号\n\t'accountSid' =\u003e '',\n\t// 主帐号Token\n\t'accountToken' =\u003e '',\n\t// AppId 应用ID\n\t'appId' =\u003e '',\n\t// SubAccountSid 子帐号\n\t'subAccountSid' =\u003e '',\n\t// SubAccountToken 子帐号Token(密码)\n\t'subAccountToken' =\u003e '',\n\t// VoIPAccount VoIP帐号\n\t'voIPAccount' =\u003e '',\n\t// VoIPPassword VoIP密码\n\t'voIPPassword' =\u003e '', \n\t//请求地址，格式如下，不需要写https://\n\t'serverIP' =\u003e '',\n\t//请求端口\n\t'serverPort' =\u003e '',\n\t//REST版本号 云通讯固定版本号，除非官方接口升级外,不要修改版本号\n\t'softVersion' =\u003e '2013-12-26',\n\t//包体格式，可填值：json 、xml\n\t'bodyType' =\u003e 'json',\n\t//日志开关。可填值：true、false\n\t'enabeLog' =\u003e true,\n\t\n\t......\n];\n```\n\n## 主要功能\n方法名和云通讯的[测试demo](http://docs.yuntongxun.com/index.php/Demo%E4%B8%8B%E8%BD%BD)中的方法名一致,所以大家要调用什么功能,直接看官方api的方法名来使用本扩展. enjoy it!\n\n**双向回拨**\n```php\n$result = Cloud::callBack(\"呼叫号码\",\"被叫号码\");\n```\n\u003e 双向回拨是先拨打呼叫号码，等呼叫号码接通后再拨打被叫号码\n\n**发送短信**\n```php\n/**\n * 发送模板短信\n * @author 晚黎\n * @date   2016-04-08T15:11:13\n * @param  [string]                   \t$to     [接收号码]\n * @param  [array]                   \t$datas  [发送的验证码和时间['验证码','时间']]\n * @param  [int]                   \t\t$tempId [短信模板ID]\n */\n$result = Cloud::sendTemplateSMS('187********',['5564','20'],1);\n```\n\n**语音验证码**\n```php\n/**\n * 语音验证码\n * @author 晚黎\n * @date   2016-04-08T15:25:04\n * @param  [String] $verifyCode [验证码内容，为数字和英文字母，不区分大小写，长度4-8位。当playVerifyCode为空时有效，该参数和playVerifyCode二者不能同时为空，当二者都不为空时优先使用playVerifyCode。]\n * @param  [String]                   $to         [接收号码，被叫为座机时需要添加区号，如：01052823298；被叫为分机时分机号由‘-’隔开，如：01052823298-3627]\n * @param  [int]                   $playTimes  [循环播放次数，1－3次，默认播放1次。]\n * @param  [String]                   $displayNum [来电显示的号码，根据平台侧显号规则控制(有显号需求请联系云通讯商务，并且说明显号的方式)，不在平台规则内或空则显示云通讯平台默认号码。默认值空。注：来电显示的号码不能和接收验证码的号码相同，否则显示云通讯平台默认号码。]\n * @param  [String]                   $respUrl    [语音验证码状态通知回调地址（必须符合URL规范），云通讯平台将向该Url地址发送呼叫结果通知。]\n * @param  [String]                   $lang       [语言类型。取值en（英文）、zh（中文），默认值zh。]\n * @param  [String]                   $userData   [第三方私有数据，可在语音验证码状态通知中获取此参数。]\n */\n$result = Cloud::voiceVerify($verifyCode,$to,$playTimes = '',$displayNum = 1,$respUrl = '',$lang = 'zh',$userData = '');\n```\n...\n\n除了上面主要方法,还有其他的一些方法就不描述了，下面是荣联云的接口所有方法：\n\n```php\n\u003c?php\nnamespace Lance\\Cloud;\n/**\n * 云通讯接口\n */\ninterface CloudCommunicationContract{\n\t/**\n\t * 打印日志\n\t * @author 晚黎\n\t * @date   2016-04-06T15:45:01+0800\n\t * @param  [type]                   $log [日志内容]\n\t * @return [type]                        [description]\n\t */\n\tpublic function showlog($log);\n\t/**\n\t * 发起HTTPS请求\n\t * @author 晚黎\n\t * @date   2016-04-06T15:45:47+0800\n\t * @param  [type]                   $url    [请求地址]\n\t * @param  [type]                   $data   [请求包体]\n\t * @param  [type]                   $header [请求包头]\n\t * @param  integer                  $post   [请求方式 默认为1 1：post，0：get]\n\t * @return [type]                           [description]\n\t */\n\tpublic function curl_post($url,$data,$header,$post=1);\n\t/**\n\t * 创建子帐号\n\t * @author 晚黎\n\t * @date   2016-04-06T15:47:12+0800\n\t * @param  [type]                   $friendlyName [子帐号名称]\n\t * @return [type]                                 [description]\n\t */\n\tpublic function createSubAccount($friendlyName);\n\n\t/**\n\t * 获取子帐号\n\t * @author 晚黎\n\t * @date   2016-04-06T15:48:30+0800\n\t * @param  [type]                   $startNo [开始的序号，默认从0开始]\n\t * @param  [type]                   $offset  [一次查询的最大条数，最小是1条，最大是100条]\n\t * @return [type]                            [description]\n\t */\n\tpublic function getSubAccounts($startNo,$offset);\n\n\t/**\n\t * 子帐号信息查询\n\t * @author 晚黎\n\t * @date   2016-04-06T15:50:11+0800\n\t * @param  [type]                   $friendlyName [子帐号名称]\n\t * @return [type]                                 [description]\n\t */\n\tpublic function querySubAccount($friendlyName);\n\n\t/**\n\t * 发送模板短信\n\t * @author 晚黎\n\t * @date   2016-04-06T15:50:58+0800\n\t * @param  [type]                   $to     [短信接收彿手机号码集合,用英文逗号分开]\n\t * @param  [type]                   $datas  [内容数据]\n\t * @param  [type]                   $tempId [模板Id]\n\t * @return [type]                           [description]\n\t */\n\tpublic function sendTemplateSMS($to,$datas,$tempId);\n\n\t/**\n\t * 双向回呼\n\t * @author 晚黎\n\t * @date   2016-04-06T15:51:59+0800\n\t * @param  [type]\t$from            [主叫电话号码]\n\t * @param  [type]\t$to              [被叫电话号码]\n\t * $options数组中的key：\n\t * @param  [type]\tcustomerSerNum  [被叫侧显示的客服号码]\n\t * @param  [type]\tfromSerNum      [主叫侧显示的号码]\n\t * @param  [type]\tpromptTone      [自定义回拨提示音]\n\t * @param  [type]\talwaysPlay      [第三方私有数据]\n\t * @param  [type]\tterminalDtmf    [最大通话时长]\n\t * @param  [type]\tuserData        [实时话单通知地址]\n\t * @param  [type]\tmaxCallTime     [是否一直播放提示音]\n\t * @param  [type]\thangupCdrUrl    [用于终止播放promptTone参数定义的提示音]\n\t * @param  [type]\tneedBothCdr     [是否给主被叫发送话单]\n\t * @param  [type]\tneedRecord      [是否录音]\n\t * @param  [type]\tcountDownTime   [设置倒计时时间]\n\t * @param  [type]\tcountDownPrompt [倒计时时间到后播放的提示音]\n\t */\n\tpublic function callBack($from,$to,$options=[]);\n\n\t/**\n\t * 外呼通知\n\t * @author 晚黎\n\t * @date   2016-04-06T15:53:57+0800\n\t * @param  [type]                   $to          [被叫号码]\n\t * @param  [type]                   $mediaName   [语音文件名称，格式 wav。与mediaTxt不能同时为空。当不为空时mediaTxt属性失效。]\n\t * @param  [type]                   $mediaTxt    [文本内容]\n\t * @param  [type]                   $displayNum  [显示的主叫号码]\n\t * @param  [type]                   $playTimes   [循环播放次数，1－3次，默认播放1次。]\n\t * @param  [type]                   $respUrl     [外呼通知状态通知回调地址，云通讯平台将向该Url地址发送呼叫结果通知。]\n\t * @param  [type]                   $userData    [用户私有数据]\n\t * @param  [type]                   $maxCallTime [最大通话时长]\n\t * @param  [type]                   $speed       [发音速度]\n\t * @param  [type]                   $volume      [音量]\n\t * @param  [type]                   $pitch       [音调]\n\t * @param  [type]                   $bgsound     [背景音编号]\n\t * @return [type]                                [description]\n\t */\n\tpublic function landingCall($to,$mediaName,$mediaTxt,$displayNum,$playTimes,$respUrl,$userData,$maxCallTime,$speed,$volume,$pitch,$bgsound);\n\n\t/**\n\t * 语音验证码\n\t * @author 晚黎\n\t * @date   2016-04-06T15:55:15+0800\n\t * @param  [type]                   $verifyCode [验证码内容，为数字和英文字母，不区分大小写，长度4-8位]\n\t * @param  [type]                   $playTimes  [播放次数，1－3次]\n\t * @param  [type]                   $to         [接收号码]\n\t * @param  [type]                   $displayNum [显示的主叫号码]\n\t * @param  [type]                   $respUrl    [语音验证码状态通知回调地址，云通讯平台将向该Url地址发送呼叫结果通知]\n\t * @param  [type]                   $lang       [语言类型]\n\t * @param  [type]                   $userData   [第三方私有数据]\n\t * @return [type]                               [description]\n\t */\n\tpublic function voiceVerify($verifyCode,$playTimes,$to,$displayNum,$respUrl,$lang,$userData);\n\n\t/**\n\t * IVR外呼\n\t * @author 晚黎\n\t * @date   2016-04-06T15:56:20+0800\n\t * @param  [type]                   $number   [待呼叫号码，为Dial节点的属性]\n\t * @param  [type]                   $userdata [用户数据，在\u003cstartservice\u003e通知中返回，只允许填写数字字符，为Dial节点的属性]\n\t * @param  [type]                   $record   [是否录音，可填项为true和false，默认值为false不录音，为Dial节点的属性]\n\t * @return [type]                             [description]\n\t */\n\tpublic function ivrDial($number,$userdata,$record);\n\n\t/**\n\t * 话单下载\n\t * @author 晚黎\n\t * @date   2016-04-06T15:57:34+0800\n\t * @param  [type]                   $date     [day 代表前一天的数据（从00:00 – 23:59）]\n\t * @param  [type]                   $keywords [客户的查询条件，由客户自行定义并提供给云通讯平台。默认不填忽略此参数]\n\t * @return [type]                             [description]\n\t */\n\tpublic function billRecords($date,$keywords);\n\n\t/**\n\t * 主帐号信息查询\n\t * @author 晚黎\n\t * @date   2016-04-06T15:58:14+0800\n\t * @return [type]                   [description]\n\t */\n\tpublic function queryAccountInfo();\n\n\t/**\n\t * 短信模板查询\n\t * @author 晚黎\n\t * @date   2016-04-06T15:58:45+0800\n\t * @param  [type]                   $templateId [模板ID]\n\t */\n\tpublic function querySMSTemplate($templateId);\n\n\t/**\n\t * 取消回拨\n\t * @author 晚黎\n\t * @date   2016-04-06T15:59:15+0800\n\t * @param  [type]                   $callSid [一个由32个字符组成的电话唯一标识符]\n\t * @param  [type]                   $type    [0： 任意时间都可以挂断电话；1 ：被叫应答前可以挂断电话，其他时段返回错误代码；2： 主叫应答前可以挂断电话，其他时段返回错误代码；默认值为0。]\n\t */\n\tpublic function callCancel($callSid,$type);\n\n\t/**\n\t * 呼叫状态查询\n\t * @author 晚黎\n\t * @date   2016-04-06T16:00:13+0800\n\t * @param  [type]                   $callid [呼叫Id ]\n\t * @param  [type]                   $action [查询结果通知的回调url地址]\n\t */\n\tpublic function queryCallState($callid,$action);\n\n\t/**\n\t * 呼叫结果查询\n\t * @author 晚黎\n\t * @date   2016-04-06T16:00:55+0800\n\t * @param  [type]                   $callSid [呼叫SId]\n\t */\n\tpublic function callResult($callSid);\n\n\t/**\n\t * 语音文件上传\n\t * @author 晚黎\n\t * @date   2016-04-06T16:01:32+0800\n\t * @param  [type]                   $filename [文件名]\n\t * @param  [type]                   $body     [二进制串]\n\t */\n\tpublic function mediaFileUpload($filename,$body);\n\n\t/**\n\t * 子帐号鉴权\n\t * @author 晚黎\n\t * @date   2016-04-06T16:02:07+0800\n\t */\n\tpublic function subAuth();\n\n\t/**\n\t * 主帐号鉴权\n\t * @author 晚黎\n\t * @date   2016-04-06T16:03:45+0800\n\t */\n\tpublic function accAuth();\n}\n```\n\n## 返回值\n调用任何方法后都会返回一个数组,数组中结构如下：\n\n**请求失败**\n```php\n[\n  \"resultStatus\" =\u003e \"0\"\n  \"errorMsg\" =\u003e \"result error!\"\n]\n```\n\n**验证错误**\n```php\n[\n\t'resultStatus' =\u003e '0' , \n\t'errorCode' =\u003e '错误码' , \n\t'errorMsg' =\u003e '错误信息'\n]\n```\n\n**成功**\n```php\n[\n\t'resultStatus' =\u003e '1' , \n\t....\n]\n```\n\u003e成功后的返回值都不同,返回的字段参考官方API文档\n\n## 问题反馈\n如果有什么Bug，反应反馈：`709344897@qq.com`","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flancewan%2Flaravel5-cloud","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flancewan%2Flaravel5-cloud","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flancewan%2Flaravel5-cloud/lists"}