首页 > 帮助中心
自动上链,就是有买家在本平台下单购买您网站的友情链接,订单 5 分钟内自动生效,并且上链到您的网站友情链接位置;订单过期后自动下链,无需人工操作,坐等月结提现即可。如果自动上链失败,会转变成故障订单,短信通知卖家上链。
需要自己写程序调用我们的接口,将返回的 HTML 输出到网站友链位置即可。
| 参数 | 必填 | 默认值 | 说明 |
|---|---|---|---|
domain |
是 | — | 您的域名,如 www.xxxxx.com |
user_id |
是 | — | 用户 ID,登录后可见,请替换示例中的 ID |
type |
否 | 1 |
返回数据的输出格式: |
return_type |
否 | 1 |
返回哪些订单: |
position |
否 | 1 |
按位置筛选: |
test |
否 | — |
开发调试用,传 1 时无订单也会返回
<a href="https://www.51link.com" target="_blank">链接平台(51链)</a>;
正式环境请勿使用
|
代码示例(切换语言查看,每种语言仅保留一个推荐写法)
<?php $url = 'http://api.51link.com/auto-link.api?domain=www.520dir.com&type=1&return_type=1&user_id=登录可见'; $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 2); curl_setopt($ch, CURLOPT_TIMEOUT, 2); $result = curl_exec($ch); curl_close($ch); echo urldecode($result);
import urllib.request
from urllib.parse import unquote
url = 'http://api.51link.com/auto-link.api?domain=www.520dir.com&type=1&return_type=1&user_id=登录可见'
with urllib.request.urlopen(url, timeout=2) as resp:
print(unquote(resp.read().decode('utf-8')))
const http = require('http');
const url = 'http://api.51link.com/auto-link.api?domain=www.520dir.com&type=1&return_type=1&user_id=登录可见';
http.get(url, { timeout: 2000 }, (res) => {
let data = '';
res.on('data', (chunk) => { data += chunk; });
res.on('end', () => console.log(decodeURIComponent(data)));
}).on('error', (err) => console.error(err));
package main
import (
"fmt"
"io"
"net/http"
"net/url"
"time"
)
func main() {
apiURL := "http://api.51link.com/auto-link.api?domain=www.520dir.com&type=1&return_type=1&user_id=登录可见"
client := &http.Client{Timeout: 2 * time.Second}
resp, err := client.Get(apiURL)
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
decoded, _ := url.QueryUnescape(string(body))
fmt.Println(decoded)
}
import java.net.URI;
import java.net.URLDecoder;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.nio.charset.StandardCharsets;
import java.time.Duration;
public class AutoLink {
public static void main(String[] args) throws Exception {
String apiUrl = "http://api.51link.com/auto-link.api?domain=www.520dir.com&type=1&return_type=1&user_id=登录可见";
HttpClient client = HttpClient.newBuilder()
.connectTimeout(Duration.ofSeconds(2))
.build();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(apiUrl))
.timeout(Duration.ofSeconds(2))
.GET()
.build();
String result = client.send(request, HttpResponse.BodyHandlers.ofString()).body();
System.out.println(URLDecoder.decode(result, StandardCharsets.UTF_8));
}
}
自动上链订单一般在 5 分钟内生效。如果自动上链异常,将会发短信通知卖家上链。