快速开始
查看CURL、PHP、Node、Golang代码示例,代码可直接运行成功,其他开发语言可参考通用http接口定义。
PDF文件合并
- CURL
- PHP
- Node
- Golang
curl -X POST 'https://test-rest-api.easyyun.com/v1/router/rest' \
-d 'method=pdf.merge' \
-d 'token=395a25d6fa758bfb6c0d3da007a8b189' \
-d 'input={"file_url":["https://static.easyyun.com/static/example/files/one_page.pdf","https://static.easyyun.com/static/example/files/two_pages.pdf"]}'
<?php
// PDF文件合并
$url = 'https://test-rest-api.easyyun.com/v1/router/rest';
$method = "pdf.merge";
//测试token,无法更新,使用参考 https://www.easyyun.com/docs/api/base#token
$token = '395a25d6fa758bfb6c0d3da007a8b189';
$input = json_encode([
'file_url' =>[
'https://static.easyyun.com/static/example/files/one_page.pdf',
'https://static.easyyun.com/static/example/files/two_pages.pdf'
]
]);
$body = [
'method' => $method,
'token' => $token,
'input' => $input,
];
$body_string = http_build_query($body, '', '&');
$curl = curl_init();
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_FAILONERROR, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_POSTFIELDS, $body_string);
$response = curl_exec($curl);
echo $response;
?>
// PDF文件合并
var request = require("request");
var url = "https://test-rest-api.easyyun.com/v1/router/rest";
var method = "pdf.merge";
//测试token,无法更新,使用参考 https://www.easyyun.com/docs/api/base#token
var token = "395a25d6fa758bfb6c0d3da007a8b189";
var input = '{"file_url":["https://static.easyyun.com/static/example/files/one_page.pdf","https://static.easyyun.com/static/example/files/two_pages.pdf"]}';
var body = "method=" + method + "&token=" + token + "&input=" + input;
request({
url: url,
method: "POST",
headers: {
"content-type": "application/x-www-form-urlencoded",
},
body: body
}, function(error, response, body) {
console.log(body);
});
package main
import (
"fmt"
"io/ioutil"
"net/http"
"strings"
)
// PDF文件合并
func main() {
url := "https://test-rest-api.easyyun.com/v1/router/rest"
method := "pdf.merge"
// token,测试token,无法更新,使用参考 https://www.easyyun.com/docs/api/base#token
token := "395a25d6fa758bfb6c0d3da007a8b189"
// input 远程文件地址
input := "{\"file_url\":[\"https://static.easyyun.com/static/example/files/one_page.pdf\",\"https://static.easyyun.com/static/example/files/two_pages.pdf\"]}"
payload := strings.NewReader("method=" + method + "&token=" + token + "&input=" + input)
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("content-type", "application/x-www-form-urlencoded")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(string(body))
}
PDF转图片
- CURL
- PHP
- Node
- Golang
curl -X POST 'https://test-rest-api.easyyun.com/v1/router/rest' \
-d 'method=pdf.splitToImage' \
-d 'token=395a25d6fa758bfb6c0d3da007a8b189' \
-d 'async=0' \
-d 'input=https://static.easyyun.com/static/example/files/four_pages.pdf' \
-d 'options={"quality": "middle", "page": "1-N"}'
<?php
// PDF转图片
$url = 'https://test-rest-api.easyyun.com/v1/router/rest';
$method = 'pdf.splitToImage';
//测试token,无法更新,使用参考 https://www.easyyun.com/docs/api/base#token
$token = '395a25d6fa758bfb6c0d3da007a8b189';
$input = 'https://static.easyyun.com/static/example/files/four_pages.pdf';
// $options: quality图片质量为中,1-N为多页
$options = json_encode([
'quality' => 'middle',
'page' => '1-N', // (多张图片)
]);
$body = [
'method' => $method,
'token' => $token,
'input' => $input,
'options' => $options
];
$body_string = http_build_query($body, '', '&');
$curl = curl_init();
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_FAILONERROR, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_POSTFIELDS, $body_string);
$response = curl_exec($curl);
echo $response;
?>
// PDF转图片
var request = require("request");
var url = "https://test-rest-api.easyyun.com/v1/router/rest";
var method = "pdf.splitToImage";
//测试token,无法更新,使用参考 https://www.easyyun.com/docs/api/base#token
var token = "395a25d6fa758bfb6c0d3da007a8b189";
var input = "https://static.easyyun.com/static/example/files/four_pages.pdf";
// options: quality图片质量为中,1-N为多页
var options = JSON.stringify({quality: 'middle',page: '1-N'});
var body = "method=" + method + "&token=" + token + "&input=" + input + "&options=" + options;
request({
url: url,
method: "POST",
headers: {
"content-type": "application/x-www-form-urlencoded",
},
body: body
}, function(error, response, body) {
console.log(body);
});
package main
import (
"fmt"
"io/ioutil"
"net/http"
"strings"
)
// PDF转图片
func main() {
url := "https://test-rest-api.easyyun.com/v1/router/rest"
method := "pdf.splitToImage"
// token,测试token,无法更新,使用参考 https://www.easyyun.com/docs/api/base#token
token := "395a25d6fa758bfb6c0d3da007a8b189"
// input 远程文件地址
input := "https://static.easyyun.com/static/example/files/four_pages.pdf"
// options: quality图片质量为中,1-N为多页
options := "{\"quality\": \"middle\", \"page\": \"1-N\"}"
payload := strings.NewReader("method=" + method + "&token=" + token + "&input=" + input + "&options=" + options)
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("content-type", "application/x-www-form-urlencoded")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(string(body))
}
继续探索
完成了体验后,更多API:参考