|
| 1 | +# AgoraSDK |
| 2 | + |
| 3 | +[![Latest Version on Packagist][ico-version]][link-packagist] |
| 4 | +[![Total Downloads][ico-downloads]][link-downloads] |
| 5 | +[![Build Status][ico-travis]][link-travis] |
| 6 | +[![StyleCI][ico-styleci]][link-styleci] |
| 7 | + |
| 8 | +This is where your description should go. Take a look at [contributing.md](contributing.md) to see a to do list. |
| 9 | + |
| 10 | +## Installation |
| 11 | + |
| 12 | +Via Composer |
| 13 | + |
| 14 | +``` bash |
| 15 | +$ composer require willywes/agora-sdk-php |
| 16 | +``` |
| 17 | + |
| 18 | +## Usage |
| 19 | + |
| 20 | +``` php |
| 21 | +use Willywes\AgoraSDK\RtcTokenBuilder; |
| 22 | + |
| 23 | +class AgoraHelper |
| 24 | +{ |
| 25 | + public static function GetToken($user_id){ |
| 26 | + |
| 27 | + $appID = "72fc..."; |
| 28 | + $appCertificate = "72fc..."; |
| 29 | + $channelName = "Test"; |
| 30 | + $uid = $user_id; |
| 31 | + $uidStr = ($user_id) . ''; |
| 32 | + $role = RtcTokenBuilder::RoleAttendee; |
| 33 | + $expireTimeInSeconds = 3600; |
| 34 | + $currentTimestamp = (new \DateTime("now", new \DateTimeZone('UTC')))->getTimestamp(); |
| 35 | + $privilegeExpiredTs = $currentTimestamp + $expireTimeInSeconds; |
| 36 | + |
| 37 | + return RtcTokenBuilder::buildTokenWithUid($appID, $appCertificate, $channelName, $uid, $role, $privilegeExpiredTs); |
| 38 | + |
| 39 | + } |
| 40 | +} |
| 41 | +``` |
| 42 | + |
| 43 | +``` php |
| 44 | + $user = auth()->user(); |
| 45 | + $agora_token = AgoraHelper::GetToken($user->id); |
| 46 | +``` |
| 47 | +## Change log |
| 48 | + |
| 49 | +Please see the [changelog](changelog.md) for more information on what has changed recently. |
| 50 | + |
| 51 | +## Testing |
| 52 | + |
| 53 | +``` bash |
| 54 | +$ composer test |
| 55 | +``` |
| 56 | + |
| 57 | +## Contributing |
| 58 | + |
| 59 | +Please see [contributing.md](contributing.md) for details and a todolist. |
| 60 | + |
| 61 | +## Security |
| 62 | + |
| 63 | +If you discover any security related issues, please email author email instead of using the issue tracker. |
| 64 | + |
| 65 | +## Credits |
| 66 | + |
| 67 | +- [author name][link-author] |
| 68 | +- [All Contributors][link-contributors] |
| 69 | + |
| 70 | +## License |
| 71 | + |
| 72 | +license. Please see the [license file](license.md) for more information. |
| 73 | + |
| 74 | +[ico-version]: https://img.shields.io/packagist/v/willywes/agora-sdk-php.svg?style=flat-square |
| 75 | +[ico-downloads]: https://img.shields.io/packagist/dt/willywes/agora-sdk-php.svg?style=flat-square |
| 76 | +[ico-travis]: https://img.shields.io/travis/willywes/agora-sdk-php/master.svg?style=flat-square |
| 77 | +[ico-styleci]: https://styleci.io/repos/12345678/shield |
| 78 | + |
| 79 | +[link-packagist]: https://packagist.org/packages/willywes/agora-sdk-php |
| 80 | +[link-downloads]: https://packagist.org/packages/willywes/agora-sdk-php |
| 81 | +[link-travis]: https://travis-ci.org/willywes/agora-sdk-php |
| 82 | +[link-styleci]: https://styleci.io/repos/12345678 |
| 83 | +[link-author]: https://github.com/willywes |
| 84 | +[link-contributors]: ../../contributors |
0 commit comments