Skip to content

Commit 1ea2d23

Browse files
author
leander
committed
repo init
1 parent 0e8624b commit 1ea2d23

File tree

6 files changed

+76
-3
lines changed

6 files changed

+76
-3
lines changed

.gitignore

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# local files #
2+
/vendor/
3+
/composer.lock
4+
5+
# sensitive files #
6+
/src/conf.class.php

README.md

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# php-sdk-aliyun
2+
3+
阿里云第三方PHP-SDK,目前维护者只有一人,出于项目需要与兴趣维护她。如果你有bug反馈欢迎提供issues,如果你对项目维护迭代有想法,也欢迎[@leander](mailto:[email protected])
4+
5+
## 安装
6+
7+
- composer安装
8+
9+
```cli
10+
composer require leander/aliyun-sdk
11+
```
12+
13+
## 配置
14+
15+
你应该创建/youdao-ai/src/conf.inc.php.example副本/youdao-ai/src/conf.inc.php:
16+
17+
```shell
18+
cd youdao-ai
19+
cp /src/conf.inc.php.example /src/conf.inc.php
20+
```
21+
22+
### 配置项参照表如下:
23+
24+
名称 | 别名 | 默认值 | 版本支持 | 备注
25+
------ | ------ | ------ | ------ | ------
26+
应用参数 | | | |
27+
API_SERV | api服务器 | <http://openapi.youdao.com/> | ~1.0 |
28+
APP_KEY | 应用编号 | | ~1.0 |
29+
SEC_KEY | 应用密钥 | | ~1.0 |
30+
HTTP参数 | | | |
31+
HTTP_TIMEOUT | 超时时间 | 10 | ~1.0 | 超过设定值(秒),超时失败
32+
API_PATH | 接口映射表 | | ~1.0 | 配置组,通常不需要修改
33+
34+
## 文档
35+
36+
请自行查阅官方文档,了解各接口作用:<https://ai.youdao.com/docs/doc-trans-api.s#p01>
37+
我们对接口名进行了抽象映射,接口目录如下:
38+
39+
映射名 | 官方路径 | 别名 | 参数 | 描述 | 备注
40+
------ | ------ | ------ | ------ | ------ | ------
41+
trans | api | 自然语言翻译 | ... | ...
42+
sti | speechtransapi | 语音翻译 | ... | ...
43+
oti | ocrtransapi | ocr文档翻译 | ... | ...
44+
45+
## 其他说明
46+
47+

composer.json

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"name": "leander/aliyun-sdk",
3+
"description": "a third-party php sdk based aliyun api",
4+
"type": "library",
5+
"require": {
6+
"guzzlehttp/guzzle": "^6.3"
7+
},
8+
"license": "apache-2.0",
9+
"authors": [
10+
{
11+
"name": "leander",
12+
"email": "[email protected]"
13+
}
14+
],
15+
"minimum-stability": "beta"
16+
}

docs/.gitignore

Whitespace-only changes.

src/conf.class.php.example

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
define('ACCESSKEY', 'your ak');
2+
define('ACCESSSECRET', 'your as');

src/index.php src/sdk.class.php

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
<?php
2+
require_once 'conf.class.php';
3+
24
// 禁止远程调用
35
$_SERVER['SERVER_ADDR'] === '127.0.0.1' OR exit('No Remote Calls!');
46

@@ -13,8 +15,8 @@ function_exists('ini_set') && ini_set('display_errors', TRUE);
1315
use Roura\Alicloud\V20150109\AlicloudUpdateRecord;
1416

1517
// 此处填入阿里云AccessKey参数
16-
$AccessKeyId = 'your accesskey';
17-
$AccessKeySecret = 'your accesssecret';
18+
$AccessKeyId = ACCESSKEY;
19+
$AccessKeySecret = ACCESSSECRET;
1820
$updater = new AlicloudUpdateRecord($AccessKeyId, $AccessKeySecret);
1921

2022
// 使用IP API服务(http://ip-api.com)获取当前服务器公网IP
@@ -32,4 +34,4 @@ function_exists('ini_set') && ini_set('display_errors', TRUE);
3234
// 记录成功发送的响应日志
3335
$msg = date('Y-m-d H:i:s').' Ip['.$newIp.'] caught, return code is "'.($res['Code']? $res['Code']: 'Success').'"['.$res['RequestId'].']'.PHP_EOL;
3436
file_put_contents('log/UpdateDomainRecord_'.date('y-m').'.log', $msg, FILE_APPEND);
35-
exit($msg);
37+
exit($msg);

0 commit comments

Comments
 (0)