Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
数据应用
ThinkLibrary
提交
c77ab7f4
T
ThinkLibrary
项目概览
数据应用
/
ThinkLibrary
通知
2
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
代码片段
项目成员
Pages
T
ThinkLibrary
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
c77ab7f4
编写于
5月 20, 2020
作者:
李光春
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
- 优化
上级
6338e136
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
178 addition
and
33 deletion
+178
-33
README.md
README.md
+70
-22
src/Library.php
src/Library.php
+1
-3
src/config.php
src/config.php
+11
-0
src/exception/AliException.php
src/exception/AliException.php
+32
-0
src/exception/BaiduException.php
src/exception/BaiduException.php
+32
-0
src/service/MacService.php
src/service/MacService.php
+1
-7
src/service/amap/AmApService.php
src/service/amap/AmApService.php
+14
-0
src/service/baidu/LbsYunService.php
src/service/baidu/LbsYunService.php
+17
-1
未找到文件。
README.md
浏览文件 @
c77ab7f4
...
...
@@ -19,13 +19,13 @@
-
Github仓库地址:https://github.com/GC0202/ThinkLibrary
-
码云仓库地址:https://gitee.com/liguangchun/ThinkLibrary
-
gitlab:https://gitlab.com/liguangchun/thinklibrary
-
阿里云仓库地址:https://
github.com/GC0202
/ThinkLibrary
-
CODING:https://liguangchun-01.coding.net/p/ThinkLibrary/d/ThinkLibrary/git
-
CODING:https://aizhineng.coding.net/p/ThinkLibrary/d/ThinkLibrary/git
-
腾讯云:https://liguangchundt.coding.net/p/ThinkLibrary/d/ThinkLibrary/git
-
微信:https://git.weixin.qq.com/liguangchun/ThinkLibrary
-
华为云:https://codehub-cn-south-1.devcloud.huaweicloud.com/composer00001/ThinkLibrary.git
-
gitlab
仓库地址
:https://gitlab.com/liguangchun/thinklibrary
-
阿里云仓库地址:https://
code.aliyun.com/liguancghun
/ThinkLibrary
-
CODING
仓库地址
:https://liguangchun-01.coding.net/p/ThinkLibrary/d/ThinkLibrary/git
-
CODING
仓库地址
:https://aizhineng.coding.net/p/ThinkLibrary/d/ThinkLibrary/git
-
腾讯云
仓库地址
:https://liguangchundt.coding.net/p/ThinkLibrary/d/ThinkLibrary/git
-
微信
仓库地址
:https://git.weixin.qq.com/liguangchun/ThinkLibrary
-
华为云
仓库地址
:https://codehub-cn-south-1.devcloud.huaweicloud.com/composer00001/ThinkLibrary.git
### 开发版
```
text
...
...
@@ -49,42 +49,90 @@ composer update liguangchun/think-library -vvv
composer remove liguangchun/think-library -vvv
```
## 获取电脑Mac地址服务使用示例
```
php
use
DtApp\ThinkLibrary\service\MacService
;
dump
(
MacService
::
instance
()
->
get
());
```
## 百度地图服务使用示例
```
php
use
DtApp\ThinkLibrary\exception\CurlException
;
use
DtApp\ThinkLibrary\service\baidu\LbsYunService
;
try
{
// 获取天气信息
dump
(
LbsYunService
::
instance
()
->
ak
(
""
)
->
weather
());
}
catch
(
CurlException
$e
)
{
dump
(
$e
->
getMessage
());
}
```
## 高德地图服务使用示例
```
php
use
DtApp\ThinkLibrary\exception\CurlException
;
use
DtApp\ThinkLibrary\service\amap\AmApService
;
try
{
// 获取天气信息
dump
(
AmApService
::
instance
()
->
key
(
""
)
->
weather
());
}
catch
(
CurlException
$e
)
{
dump
(
$e
->
getMessage
());
}
```
## 抖音服务使用示例
```
text
```
php
use DtApp\ThinkLibrary\
service\douyi
n\DouYinException;
use
DtApp\ThinkLibrary\
exceptio
n\DouYinException
;
use
DtApp\ThinkLibrary\service\douyin\WatermarkService
;
try
{
// 方法一 网址
var_
dump(WatermarkService::instance()->url('https://v.douyin.com/vPGAdM/')->getAll()->toArray());
dump
(
WatermarkService
::
instance
()
->
url
(
'https://v.douyin.com/vPGAdM/'
)
->
getAll
()
->
toArray
());
// 方法一 粘贴
var_
dump(WatermarkService::instance()->url('#在抖音,记录美好生活#美丽电白欢迎您 https://v.douyin.com/vPGAdM/ 复制此链接,打开【抖音短视频】,直接观看视频!')->getAll()->toArray());
dump
(
WatermarkService
::
instance
()
->
url
(
'#在抖音,记录美好生活#美丽电白欢迎您 https://v.douyin.com/vPGAdM/ 复制此链接,打开【抖音短视频】,直接观看视频!'
)
->
getAll
()
->
toArray
());
// 方法二 网址
$dy
=
WatermarkService
::
instance
()
->
url
(
'https://v.douyin.com/vPafcr/'
);
var_
dump($dy->getAll()->toArray());
dump
(
$dy
->
getAll
()
->
toArray
());
// 方法二 粘贴
$dy
=
WatermarkService
::
instance
()
->
url
(
'#在抖音,记录美好生活#2020茂名加油,广州加油,武汉加油!中国加油,众志成城!#航拍 #茂名#武汉 #广州 #旅拍 @抖音小助手 https://v.douyin.com/vPafcr/ 复制此链接,打开【抖音短视频】,直接观看视频!'
);
var_
dump($dy->getAll()->toArray());
dump
(
$dy
->
getAll
()
->
toArray
());
// 获取全部信息
var_
dump(WatermarkService::instance()->url('https://v.douyin.com/vPGAdM/')->getAll()->toArray());
dump
(
WatermarkService
::
instance
()
->
url
(
'https://v.douyin.com/vPGAdM/'
)
->
getAll
()
->
toArray
());
// 获取原全部信息
var_
dump(WatermarkService::instance()->url('https://v.douyin.com/vPGAdM/')->getApi()->toArray());
dump
(
WatermarkService
::
instance
()
->
url
(
'https://v.douyin.com/vPGAdM/'
)
->
getApi
()
->
toArray
());
// 获取视频信息
var_
dump(WatermarkService::instance()->url('https://v.douyin.com/vPGAdM/')->getVideoInfo()->toArray());
dump
(
WatermarkService
::
instance
()
->
url
(
'https://v.douyin.com/vPGAdM/'
)
->
getVideoInfo
()
->
toArray
());
// 获取音频信息
var_
dump(WatermarkService::instance()->url('https://v.douyin.com/vPGAdM/')->getMusicInfo()->toArray());
dump
(
WatermarkService
::
instance
()
->
url
(
'https://v.douyin.com/vPGAdM/'
)
->
getMusicInfo
()
->
toArray
());
// 获取分享信息
var_
dump(WatermarkService::instance()->url('https://v.douyin.com/vPGAdM/')->getShareInfo()->toArray());
dump
(
WatermarkService
::
instance
()
->
url
(
'https://v.douyin.com/vPGAdM/'
)
->
getShareInfo
()
->
toArray
());
// 获取作者信息
var_
dump(WatermarkService::instance()->url('https://v.douyin.com/vPGAdM/')->getAuthorInfo()->toArray());
dump
(
WatermarkService
::
instance
()
->
url
(
'https://v.douyin.com/vPGAdM/'
)
->
getAuthorInfo
()
->
toArray
());
// 返回数组数据方法
var_
dump(WatermarkService::instance()->url('https://v.douyin.com/vPGAdM/')->getAll()->toArray());
dump
(
WatermarkService
::
instance
()
->
url
(
'https://v.douyin.com/vPGAdM/'
)
->
getAll
()
->
toArray
());
// 返回Object数据方法
var_
dump(WatermarkService::instance()->url('https://v.douyin.com/vPGAdM/')->getAll()->toObject());
dump
(
WatermarkService
::
instance
()
->
url
(
'https://v.douyin.com/vPGAdM/'
)
->
getAll
()
->
toObject
());
}
catch
(
DouYinException
$e
)
{
// 错误提示
var_
dump($e->getMessage());
dump
(
$e
->
getMessage
());
}
```
src/Library.php
浏览文件 @
c77ab7f4
...
...
@@ -28,9 +28,7 @@ class Library extends \think\Service
*/
public
function
register
()
{
// 加载语言包
$this
->
app
->
lang
->
load
(
__DIR__
.
'/lang/zh-cn.php'
,
'zh-cn'
);
$this
->
app
->
lang
->
load
(
__DIR__
.
'/lang/en-us.php'
,
'en-us'
);
}
/**
...
...
src/config.php
浏览文件 @
c77ab7f4
...
...
@@ -49,5 +49,16 @@ return [
'key'
=>
''
,
// 网址
'panel'
=>
''
,
],
// 百度
'baidu'
=>
[
// 地图
'lbs'
=>
[
'ak'
=>
''
]
],
// 高德地图
'amap'
=>
[
'key'
=>
''
]
];
src/
lang/zh-c
n.php
→
src/
exception/AliExceptio
n.php
浏览文件 @
c77ab7f4
...
...
@@ -14,18 +14,19 @@
// | Packagist 地址 :https://packagist.org/packages/liguangchun/think-library
// +----------------------------------------------------------------------
return
[
'think_library_not_auth'
=>
'抱歉,没有访问该操作的权限!'
,
'think_library_not_login'
=>
'抱歉,需要登录获取访问权限!'
,
'think_library_delete_success'
=>
'恭喜, 数据删除成功!'
,
'think_library_delete_error'
=>
'抱歉,数据删除失败, 请稍候再试!'
,
'think_library_form_success'
=>
'恭喜, 数据保存成功!'
,
'think_library_form_error'
=>
'抱歉,数据保存失败, 请稍候再试!'
,
'think_library_save_success'
=>
'恭喜,数据更新成功!'
,
'think_library_save_error'
=>
'抱歉,数据更新失败, 请稍候再试!'
,
'think_library_sort_success'
=>
'恭喜,列表排序成功!'
,
'think_library_sort_error'
=>
'抱歉,列表排序失败,请稍候再试!'
,
'think_library_page_html'
=>
'共 %s 条记录,每页显示 %s 条,共 %s 页当前显示第 %s 页。'
,
'think_library_csrf_error'
=>
'表单令牌验证失败,请刷新页面再试!'
,
'think_library_queue_exist'
=>
'任务已创建,请等待处理完成!'
,
];
namespace
DtApp\ThinkLibrary\exception
;
use
Exception
;
/**
* 阿里错误处理
* Class AliException
* @package DtApp\ThinkLibrary\exception
*/
class
AliException
extends
Exception
{
public
function
errorMessage
()
{
return
$this
->
getMessage
();
}
}
src/
lang/en-us
.php
→
src/
exception/BaiduException
.php
浏览文件 @
c77ab7f4
...
...
@@ -14,18 +14,19 @@
// | Packagist 地址 :https://packagist.org/packages/liguangchun/think-library
// +----------------------------------------------------------------------
return
[
'think_library_not_auth'
=>
'Sorry, no permission to access the operation.'
,
'think_library_not_login'
=>
'Sorry, requiring login to obtain view permission.'
,
'think_library_delete_success'
=>
'Data deletion completed.'
,
'think_library_delete_error'
=>
'Sorry, data deletion failed, please try again later.'
,
'think_library_form_success'
=>
'Data saving completed.'
,
'think_library_form_error'
=>
'Sorry, data saving failed, please try again later.'
,
'think_library_save_success'
=>
'Data update completed.'
,
'think_library_save_error'
=>
'Sorry, data update failed, please try again later.'
,
'think_library_sort_success'
=>
'Modification of list sort completed.'
,
'think_library_sort_error'
=>
'Sorry, modification of list sort failed, please try again later.'
,
'think_library_page_html'
=>
'Total %s records, display %s per page, total %s page current display %s page.'
,
'think_library_csrf_error'
=>
'Form token validation failed, please refresh and try again later.'
,
'think_library_queue_exist'
=>
'Task has been created, please wait for processing to complete.'
,
];
namespace
DtApp\ThinkLibrary\exception
;
use
Exception
;
/**
* 百度错误处理
* Class BaiduException
* @package DtApp\ThinkLibrary\exception
*/
class
BaiduException
extends
Exception
{
public
function
errorMessage
()
{
return
$this
->
getMessage
();
}
}
src/service/MacService.php
浏览文件 @
c77ab7f4
...
...
@@ -25,13 +25,7 @@ use DtApp\ThinkLibrary\Service;
*/
class
MacService
extends
Service
{
private
$result
=
array
();
/**
* 所有mac地址
* @var array
*/
private
$macAddrs
=
array
();
private
$result
=
[];
/**
* 第一个mac地址
...
...
src/service/amap/AmApService.php
浏览文件 @
c77ab7f4
...
...
@@ -16,6 +16,7 @@
namespace
DtApp\ThinkLibrary\service\amap
;
use
DtApp\ThinkLibrary\exception\AliException
;
use
DtApp\ThinkLibrary\exception\CurlException
;
use
DtApp\ThinkLibrary\Service
;
use
DtApp\ThinkLibrary\service\Curl\HttpService
;
...
...
@@ -40,6 +41,16 @@ class AmApService extends Service
return
$this
;
}
/**
* 获取配置信息
* @return $this
*/
private
function
getConfig
()
{
$this
->
key
=
config
(
'dtapp.amap.key'
);
return
$this
;
}
/**
* 天气查询
* https://lbs.amap.com/api/webservice/guide/api/weatherinfo
...
...
@@ -47,9 +58,12 @@ class AmApService extends Service
* @param string $extensions
* @return array|bool|mixed|string
* @throws CurlException
* @throws AliException
*/
public
function
weather
(
$city
=
"110101"
,
$extensions
=
"base"
)
{
if
(
empty
(
$this
->
key
))
$this
->
getConfig
();
if
(
empty
(
$this
->
key
))
throw
new
AliException
(
'请检查key参数'
);
$data
=
http_build_query
([
"city"
=>
$city
,
"extensions"
=>
$extensions
,
...
...
src/service/baidu/LbsYunService.php
浏览文件 @
c77ab7f4
...
...
@@ -16,6 +16,7 @@
namespace
DtApp\ThinkLibrary\service\baidu
;
use
DtApp\ThinkLibrary\exception\BaiduException
;
use
DtApp\ThinkLibrary\exception\CurlException
;
use
DtApp\ThinkLibrary\Service
;
use
DtApp\ThinkLibrary\service\Curl\HttpService
;
...
...
@@ -40,6 +41,16 @@ class LbsYunService extends Service
return
$this
;
}
/**
* 获取配置信息
* @return $this
*/
private
function
getConfig
()
{
$this
->
ak
=
config
(
'dtapp.baidu.lbs.ak'
);
return
$this
;
}
/**
* 国内天气查询
* http://lbsyun.baidu.com/index.php?title=webapi/weather
...
...
@@ -47,10 +58,12 @@ class LbsYunService extends Service
* @param string $coordtype
* @param string $location
* @return array|bool|mixed|string
* @throws CurlException
* @throws CurlException
|BaiduException
*/
public
function
weather
(
$district_id
=
110100
,
string
$coordtype
=
"bd09ll"
,
string
$location
=
""
)
{
if
(
empty
(
$this
->
ak
))
$this
->
getConfig
();
if
(
empty
(
$this
->
ak
))
throw
new
BaiduException
(
'请检查ak参数'
);
$data
=
http_build_query
([
"district_id"
=>
$district_id
,
"coordtype"
=>
$coordtype
,
...
...
@@ -73,9 +86,12 @@ class LbsYunService extends Service
* @param string $language
* @return array|bool|mixed|string
* @throws CurlException
* @throws BaiduException
*/
public
function
weatherAbroad
(
$district_id
=
110100
,
string
$coordtype
=
"bd09ll"
,
string
$location
=
""
,
string
$language
=
"cn"
)
{
if
(
empty
(
$this
->
ak
))
$this
->
getConfig
();
if
(
empty
(
$this
->
ak
))
throw
new
BaiduException
(
'请检查ak参数'
);
$data
=
http_build_query
([
"district_id"
=>
$district_id
,
"coordtype"
=>
$coordtype
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录