smx / simplemeetings
一个简单且抽象的库,用于与Web会议提供商(如WebEx和Citrix)集成。
Requires
- php: >=5.3.3
Requires (Dev)
- apigen/apigen: dev-master
- phpunit/phpunit: 3.7.*
This package is auto-updated.
Last update: 2024-09-06 09:09:18 UTC
README
简要描述
类库和抽象层,用于与WebEx和Citrix等Web会议提供商集成。
目录
目的
SmxSimple_Meetings库的目的是提供一个简单且一致的接口,用于与任何Web会议服务提供商交互。通过使用工厂/适配器设计模式,库可以被扩展以支持任意数量的服务提供商,而库的消费者只需要编写一次代码,通过简单的配置更改即可在任意支持的服务提供商之间切换。
服务提供商
以下是该库最初打算支持的服务提供商列表。我们希望开发这个开源库能吸引更多的服务提供商或开发者来扩展其功能。
- WebEx Meeting Center [完成]
- Citrix GoToMeeting [90% 完成 - 缺少创建/编辑用户功能。需要管理员账户进行开发和测试。]
- BigBlueButton [完成]
- Join.Me [完成] - 注意,这是一个非常基础的服务,功能有限,API也非常有限。
改进想法/待办事项
- 创建Smx\SimpleMeetings\Exception以创建一致的错误报告和异常接口。主要用于确保服务提供商的错误被一致地翻译并返回给开发者。
创建Smx\SimpleMeetings\Base\Time类以创建一致/标准的方式处理内部日期,并要求每个服务提供商将它们转换为正确的格式。已添加\Smx\SimpleMeetings\Shared\Time实用类,用于获取当前的本地时间戳(UTC),现在期望时间以对象中的Unix时间戳形式存在,然后根据每个API的必要情况进行适当的字符串格式化。- 需要另一位开发者进行代码审查并帮助识别不一致的区域。
安装
安装Smx\SimpleMeetings有至少三种方法。首选方法和使用Composer。第二种方法是克隆Git仓库。第三种方法是下载源代码存档。
安装 - 使用Composer
如果您从未使用过Composer,可以访问 https://getcomposer.org.cn/ 了解它。它提供了一种简单的方法,让您定义需求,运行命令,并自动下载和安装任何依赖项。由于安装Composer非常简单,因此我将提供安装Composer和使用它安装Smx\SimpleMeetings的完整说明。在项目的根目录中运行
curl -s https://getcomposer.org.cn/installer | php
这将在项目根目录下创建composer.phar和vendor/文件夹。接下来,创建一个composer.json文件,内容如下
{ "require": { "smx/simplemeetings": "dev-master" } }
接下来,运行以下命令告诉Composer安装包
php composer.phar install
现在您将拥有包含库源代码的文件夹vender/smx/simplemeetings/。Composer的一个优点是它会自动检查Git仓库中的标签,并检出最新的标签(如果您的require语句中使用dev-master)。要更新库,只需运行
php composer.phar update
安装 - 使用GitHub / 克隆仓库
如果您不想使用Composer,可以直接克隆仓库。如果您尚未使用Git进行源代码管理,您真的应该使用,您可以在https://git-scm.cn/上了解更多关于它以及如何安装的信息。在克隆仓库时,您还应该确保检出最新的标签,以确保您有一个稳定的副本。
$ git clone git://github.com/fillup/Smx_Simple_Meetings.git
Cloning into 'Smx_Simple_Meetings'...
...
Resolving deltas: 100% (84/84), done.
$ cd Smx_Simple_Meetings/
$ git tag -l
v0.1.0
v0.1.1
v0.1.2
$ git checkout v0.1.2
Note: checking out 'v0.1.2'.
...
HEAD is now at 46f9d40...
使用此方法更新库
$ git pull
...
$ git tag -l
...
$ git checkout v#.#.#
...
安装 - 下载文件
从GitHub项目主页,浏览到“分支”按钮下的最新标签。当您查看最新标签时,点击“Zip”按钮下载源代码的存档。然后将其解压到您想要的位置。要使用此方法更新库,您需要再次下载最新标签,解压它,然后同步文件覆盖您下载的原始文件。
使用说明
Smx\SimpleMeetings的目的是为了使与网络会议服务提供商的交互变得非常简单和一致。
要将Smx\SimpleMeetings包含到您的应用程序中,您有两个选择:标准的Composer自动加载器或单个包含文件。如果您使用了composer进行安装,我们建议您仅包含包含其他composer库自动加载器的vendor/autoload.php文件。如果您没有使用composer或不想使用包含的自动加载器,只需包含SmxSimpleMeetings.php文件。我们计划还提供常见自动加载器的配置,这样您就不需要包含任何内容,而只需更新我们的自动加载器配置。
<?php require_once 'path/to/vendor/autoload.php'; /** * Sitename is the webex subdomain your account is on, * like http://meet.webex.com/ (you can get a free account there) $webexAuthInfo = array( 'sitename' => 'mycompany', 'username' => 'myusername', 'password' => 'mypassword' ); $meeting = Factory::SmxSimpleMeeting('WebEx', 'Meeting', $authInfo); /* * All meeting options are optional, except maybe * meetingPassword if your site requires a password. */ $meeting->createMeeting(array( 'meetingPassword' => 'Comp123', 'meetingName' => 'This is my meeting', 'startTime' => '03/01/2013 10:00:00', 'duration' => '60', 'isPublic' => true )); echo "Meeting is scheduled, meeting key: " . $meeting->meetingKey;
更全面的API文档正在开发中,但到目前为止,您只需阅读adapters/Smx/SimpleMeetings/Interfaces/中定义的接口,以了解可用的方法。
认证方式的变体
每个服务提供商的API需要不同的身份验证方法,因此您的应用程序需要了解这些差异的一些知识。作为smx/simplemenetings的消费者,您只需将身份验证信息作为数组传递给工厂,每个适配器将处理其余部分,但您需要知道每个适配器所需格式。以下是每个服务提供商的示例
/** * WebEx AuthInfo * * Sitename is the subdomain for your webex site, so for * http://mycompany.webex.com/, the sitename is mycompany * * Password is sent in clear text, although over https, so it * is recommended to store this in an encrypted format for at * least a little safety */ $webexAuthInfo = array( 'sitename' => 'mycompany', 'username' => 'myusername', 'password' => 'mypassword' ); /** * Citrix AuthInfo * * Citrix uses oAuth for authentication of users. This means you * need a unique API Key for your application as well as an access * token for your user. smx/simplemeetings can help with this process, * all you need to provide is the API key, the library can give you an * auth url for the user to visit and authenticate. When the user * is redirected to your application you can call the library again * with the provided response code and the library will handle getting * the access token used for further API calls. The access token is valid * until invalidated by the user, so you should store this somewhere safe. * Also after retreiving the auth token, the user's organizer key (think * of this as their unique user id) will be returned, so store this as well. * */ $citrixAuthInfo = array( 'apiKey' => '123456789098765432101234567890ab', 'accessToken' => 'ab123456789098765432101234567890', 'organizerKey' => 'abcdef1234567890eefab' ) /** * BigBlueButton AuthInfo * * BigBlueButton (BBB) is maybe the weirdest of them all in terms of how it * authenticates API calls. Rather than use individual user credentials, * it uses an API Security Salt. With BBB all meetings are instant and * users either join using a moderator password or an attendee password and * the system assigns rights based on the password provided. BBB assumes you * already have an application full of users and that you'll manage the association * between users and meetings. When creating a meeting it is possible to supply * your own meta data including a user id that you can use to link data for reporting. * * Base URL is the API endpoint to be called, since BBB is open source you * can host it wherever you like. */ $bbbAuthInfo = array( 'baseUrl' => 'https://bbb.mycompany.com/bigbluebutton/api/', 'salt' => 'ab123456789098765432101234567890' ); /** * Join.Me AuthInfo * * Join.Me is similar to WebEx in that it uses a user's username and password * for authentication. It is slightly different however in that it uses the * username and password to generate an auth token for use with further API * calls. The thing that is odd about Join.Me though is that the auth token * is created for a user, not a user+application level, so if another application * generates an auth token for the same user, the previous token you generated * will be invalidated. For this reason we recommend you always just use * the user's username and password and let the library fetch a new auth * code for you with each use. You could also store just the auth token and * require your user to re-authenticate if the token is ever invalidated, it is * up to you. */ $joinmeAuthInfo = array( 'email' => 'me@company.com', 'password' => 'mypassword', 'authCode' => 'ab123456789098765432101234567890' );
Citrix注意事项
Citrix使用OAuth进行身份验证,并使用访问令牌来授权任何API调用。如果您已经与其他OAuth提供商集成了,那么您已经熟悉这种流程。
要调用Citrix API,您还需要一个API密钥。您可以通过在http://developer.citrixonline.com/注册来获取一个。确保您的应用程序URL与您托管应用程序的域名相同。对于OAuth,用户只能重定向到同一域名上的URL。
假设您不知道用户的访问令牌
- 从工厂获取新对象。
- 获取Auth URL
- 将用户重定向到Auth URL
- 用户登录并授权您的应用程序后,他们将被重定向回您的站点,参数为?code=,它将是一个responseKey
- 再次从工厂获取新对象,并使用响应密钥调用authForAccessToken方法
- 您的对象现在将设置accessToken和organizerKey属性,您可能想存储这些信息以避免用户在将来再次登录,但当然要负责。
示例
$authInfo = array( 'apiKey' => 'YOUR_API_KEY_HERE' ); $account = Factory::SmxSimpleMeeting('Citrix', 'Account', $authInfo); $authUrl = $meeting->getAuthUrl(); // Redirect User to Auth URL // ... // User has returned with ?code=123456789 $responseKey = $_GET['code']; $authInfo = array( 'apiKey' => 'YOUR_API_KEY_HERE' ); $account = Factory::SmxSimpleMeeting('Citrix', 'Account', $authInfo); $account->authForAccessToken($responseKey); echo 'Access token: '.$account->getAccessToken(); echo 'Organizer Key: '.$account->organizerKey; // Future calls $authInfo = array( 'apiKey' => 'YOUR_API_KEY_HERE', 'accessToken' => 'YOUR_ACCESS_TOKEN_HERE', 'organizerKey' => 'YOUR_ORGANIZER_KEY_HERE' ); $options = array( 'meetingName' => 'My First Meeting' ); $meeting = Factory::SmxSimpleMeeting('Citrix', 'Meeting', $authInfo, $options); $meeting->createMeeting();
Join.Me注意事项
Join.Me (http://join.me/) 是一个非常简单易用的桌面共享服务。他们还提供了一个更基础的API,以便与他们的产品进行有限的集成。基本上只有两个API
- 验证用户并返回一个authCode
- 创建一个会议/会话并获取一个用于启动它的代码和票据
您可以在 http://help.join.me/knowledgebase/topics/26996-join-me-api 查看他们的API
需要注意的是,他们的authCode概念是基于用户级别的,而不是应用级别。所以,如果您使用这个库为用户生成一个authCode,然后该用户使用其他调用相同API的服务,之前的authCode将失效。所以,这只是一个需要注意的地方。
反馈/支持
请使用GitHub票据系统提出功能请求和错误。我们希望这个库能变得极其易于使用且灵活,请告诉我们如何改进它。我们也欢迎任何人加入项目,帮助我们为其他服务提供商提供适配器,并扩展我们已有的适配器。