File tree Expand file tree Collapse file tree 4 files changed +77
-22
lines changed
Expand file tree Collapse file tree 4 files changed +77
-22
lines changed Original file line number Diff line number Diff line change @@ -239,12 +239,14 @@ public function describeLiveStreamsOnlineList()
239239 ]);
240240 }
241241
242+
243+
242244 /**
243245 * 直播签名
244246 * @param string $streamName
245247 * @return string
246248 */
247- protected function getSign ($ streamName )
249+ public function getSign ($ streamName )
248250 {
249251 $ uri = "/ {$ this ->appName }/ {$ streamName }" ;
250252 if ($ this ->pushAuth ) {
@@ -370,4 +372,23 @@ public function getPlayUrls($streamName)
370372 'm3u8 ' => $ this ->getPlayUrlForM3U8 ($ streamName )
371373 ];
372374 }
375+
376+ /**
377+ * 设置签名过期时间
378+ * @param int $expirationTime
379+ * @return $this
380+ */
381+ public function setExpirationTime ($ expirationTime )
382+ {
383+ $ this ->expirationTime = $ expirationTime ;
384+ return $ this ;
385+ }
386+
387+ /**
388+ * 获取签名过期时间
389+ * @return int
390+ */
391+ public function getExpirationTime (){
392+ return $ this ->expirationTime ;
393+ }
373394}
Original file line number Diff line number Diff line change 1+ <?php
2+ /**
3+ * @link http://www.tintsoft.com/
4+ * @copyright Copyright (c) 2012 TintSoft Technology Co. Ltd.
5+ * @license http://www.tintsoft.com/license/
6+ */
7+
8+ namespace aliyun \test ;
9+
10+
11+ class ClientTest extends TestCase
12+ {
13+
14+ public function testExpirationTime ()
15+ {
16+ $ params = [
17+ 'action ' => 'publish ' ,
18+ 'ip ' => '127.0.0.1 ' ,
19+ 'id ' => '123456 ' ,
20+ 'app ' => 'live.cctv.com ' ,
21+ 'appname ' => 'cctv5 ' ,
22+ 'time ' => 1488966279 ,
23+ 'usrargs ' => 'vhost%3Dlive.opencoding.tv%26auth_key%3D1489569710-0-0-499df36a0e5fd6d2bdbd72b877b7896a ' ,
24+ 'node ' => 'eu6 ' ,
25+ ];
26+
27+ $ this ->client ->setExpirationTime (1488966279 );
28+ $ this ->assertEquals (1488966279 , $ this ->client ->getExpirationTime ());
29+
30+
31+ }
32+
33+ public function testSign ()
34+ {
35+ $ this ->client ->setExpirationTime (1488966279 );
36+ $ sign = $ this ->client ->getSign ('123456 ' );
37+ $ this ->assertTrue ($ this ->client ->checkSign ('123456 ' ,$ sign ));
38+
39+ $ sign = $ this ->client ->getSign ('123456 ' );
40+ $ this ->assertFalse ($ this ->client ->checkSign ('1234567 ' ,$ sign ));
41+
42+ }
43+ }
Original file line number Diff line number Diff line change 1717 * specific language governing permissions and limitations
1818 * under the License.
1919 */
20- namespace aliyun \test ;
2120
22- use aliyun \core \ Client ;
21+ namespace aliyun \test ;
2322
24- use aliyun \core \ profile \ DefaultProfile ;
23+ use aliyun \live \ Client ;
2524
2625class TestCase extends \PHPUnit_Framework_TestCase
2726{
2827
28+ /**
29+ * @var null|Client
30+ */
2931 public $ client = null ;
3032
3133 function setUp ()
3234 {
33- $ iClientProfile = DefaultProfile::getProfile ("cn-hangzhou " , "5slyhuy4sv30bmppvgew0rps " , "NGYL1I7hXC6SgSqkcE5DJdPgJM8= " );
34- $ this ->client = new Client ($ iClientProfile );
35+ $ this ->client = new Client ([
36+ 'accessKeyId ' => '123456 ' ,
37+ 'accessSecret ' => '123456 ' ,
38+ 'appName ' => 'live ' ,
39+ 'domain ' => 'live.cctv.com ' ,
40+ 'pushAuth ' => '1234567 ' ,
41+ ]);
3542 }
36-
37-
38- function getProperty ($ propertyKey )
39- {
40- $ accessKey = "" ;
41- $ accessSecret = "" ;
42- $ iClientProfile = DefaultProfile::getProfile ("cn-hangzhou " , "5slyhuy4sv30bmppvgew0rps " , "NGYL1I7hXC6SgSqkcE5DJdPgJM8= " );
43- }
44-
4543}
Original file line number Diff line number Diff line change 1010if (is_file ($ composerAutoload )) {
1111 require_once ($ composerAutoload );
1212}
13-
14- /**
15- * 配置网关
16- */
17- $ endpoint = new Endpoint ('cn-hangzhou ' , EndpointConfig::getRegionIds (), EndpointConfig::getProductDomains ());
18- EndpointProvider::setEndpoints ([ $ endpoint ]);
19-
2013require_once (__DIR__ . '/TestCase.php ' );
You can’t perform that action at this time.
0 commit comments