-
Notifications
You must be signed in to change notification settings - Fork 0
/
Test.php
40 lines (36 loc) · 1.04 KB
/
Test.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
require_once __DIR__ . '/vendor/autoload.php';
$drivers = [
[
'driver'=>'baidu',
'app_key'=>'baidu api token',
'validity' => '1-year', //有效期 永久:long-term,1年:1-year
],
[
'driver'=>'sina',
'app_key'=>'weibo api app_key'
],
[
'driver'=>'dlj',
'app_key'=>''
]
];
// include_once __DIR__.'/test_account.php';
$longUrl = 'http://www.2vm.net.cn';
foreach ($drivers as $k => $v) {
var_dump('=============[driver:'.$v['driver'].']=============');
$surl = new \bingher\surl\Surl($v);
var_dump('[+] longUrl:'.$longUrl);
$shortUrl = $surl->create($longUrl);
if ($shortUrl === false) {
var_dump('[-] create short url error:'.$surl->getError());
} else {
var_dump('shortUrl:'.$shortUrl);
}
$checkLongUrl = $surl->query($shortUrl);
if ($checkLongUrl === false) {
var_dump('[-] query short url error:'.$surl->getError());
} else {
var_dump('[+] shortUrl:'.$shortUrl.' expand long url:'.$checkLongUrl);
}
}