UrlHelper.php
1.1 KB
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
41
42
43
44
45
46
<?php
namespace common\helpers;
use common\exts\wechat\Log as WxLog;
class UrlHelper
{
/**
* 获取短地址
*/
public static function getShortUrl($url)
{
WxLog::init();
WxLog::DEBUG('UrlHelper::getShortUrl->[' . $url . ']');
$baseurl = 'http://581.so/api.php?format=json&url=' . $url;
$ch=curl_init();
curl_setopt($ch, CURLOPT_URL, $baseurl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1 );
$strRes=curl_exec($ch);
curl_close($ch);
$arrResponse=json_decode($strRes,true);
WxLog::DEBUG('UrlHelper::getShortUrl->' . $strRes);
if($arrResponse['err'])
{
return false;
}
return $arrResponse['url'];
}
/**
* 获取微信访问路径
*/
public static function getWxUrl() {
if (YII_ENV == "prod") {
$httpUrl = "https://wx.jiwork.com";
} else if (YII_ENV == "test") {
$httpUrl = "https://twx.jiwork.com";
} else {
$httpUrl = "http://localhost/jw/src/app-wx/web";
}
return $httpUrl;
}
}