| 请求类型 | 请求地址 |
| --- | --- |
| POST | http://api.laosan6.com/Api/sg11 |
| 参数名 | 类型 | 描述 |
| --- | --- | --- |
| username | String | 用户名 |
| password | String | 用户密码 |
| userkey | String | 用户密钥|
| copy | String | 加密后展示的版权或备注 |
| file | File | 文件仅支持ZIP且小于3M |
```
请求成功 -> 返回码
{
"code": "ok",
"msg": "加密成功",
"url": "返回下载参数",
}
```
~~~
请求失败 -> 返回码
{
"code": "no",
"msg": "错误信息",
}
~~~
|msg | 对应信息 |
| --- | --- |
| User does not exist | 用户不存在 |
| Password error | 用户密码错误 |
| Domain name not authorized | 请求域名不符 |
| Insufficient number of money | 用户余额不足 |
| Key error| 密钥有误 |
| user ban | 用户被禁封 |
~~~
参照代码
~~~
~~~
<?php
$url = 'http://api.laosan6.com/Api/sg11';
$file = './ftp/test.zip';
$postdata = [
'username' => '用户名',
'password' => '用户密码',
'userkey' => '用户key',
'copy' => '版权备注',
"file" => '$file'
];
$result = request_post($url,$postdata);
$status = json_decode($result,true);
if($status['code'] != 'ok'){
//加密失败,参考返回码 对应信息
}else{
//加密成功,自行进行下一步操作
}
function request_post($url = '', $post_data =0) {
if (empty($url) || empty($post_data)) {
return false;
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
$httpheader[] = "Accept:*/*";
$httpheader[] = "Accept-Encoding:gzip,deflate,sdch";
$httpheader[] = "Accept-Language:zh-CN,zh;q=0.8";
$httpheader[] = "Connection:close";
curl_setopt($ch, CURLOPT_HTTPHEADER, $httpheader);
if ($post_data) {
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
}
curl_setopt($ch, CURLOPT_ENCODING, "gzip");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$ret = curl_exec($ch);
curl_close($ch);
return $ret;
}
~~~