cURL示例
curl -X GET "http://ltapi.lontyun.com/api/douyin/index.php"
-d "apikey=value"
-d "url=value"
PHP示例
// PHP示例 - 使用cURL
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://ltapi.lontyun.com/api/douyin/index.php");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
// 请求参数
$params = [
'apikey' => 'value',
'url' => 'value',
];
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($params));
$response = curl_exec($ch);
curl_close($ch);
// 处理响应
$data = json_decode($response, true);
if ($data && isset($data['code']) && $data['code'] == 200) {
echo "请求成功";
} else {
echo "请求失败: " . ($data['message'] ?? '未知错误');
}
Python示例
# Python示例 - 使用requests库
import requests
url = "http://ltapi.lontyun.com/api/douyin/index.php"
# 请求参数
params = {
'apikey': 'value',
'url': 'value',
}
response = requests.get(url, params=params)
data = response.json()
if data.get('code') == 200:
print("请求成功")
else:
print(f"请求失败: {data.get('message', '未知错误')}")
Node.js示例
// Node.js示例 - 使用axios
const axios = require('axios');
const url = "http://ltapi.lontyun.com/api/douyin/index.php";
// 请求参数
const params = {
apikey: 'value',
url: 'value',
};
axios.get(url, { params })
.then(response => {
const data = response.data;
if (data.code === 200) {
console.log("请求成功");
} else {
console.log(`请求失败: ${data.message || '未知错误'}`);
}
})
.catch(error => {
console.error("请求错误:", error.message);
});