GET请求 POST请求 快速使用

准备工作

您需要先注册一个账号,获取KEY。
请求地址
请求类型 HTTPS请求地址
{{view.block==='apiget'?'GET':'POST'}} https://api.70i.cn/api?key=您的KEY
请求参数
参数 类型 是否必填 描述 示例值
url String 要缩短的网址,使用双下划线“__”分割 https://api.70i.cn__https://api.70i.cn
title String URL标题 abc
expire String|Int url过期时间,
【String】 custom:自定义时间
【Int】 30:30天后过期
30
expire_date String url过期自定义时间,当expire为custom此项必填 2019-6-9
pass String 是否开启密码访问,为空则不开启 123456
is_wx Int 是否开启微信检测
1,不开启
0,开启
1
pc String 设备路由,如若是pc端请求,则跳转此地址 https://www.70i.cn
mobile String 设备路由,如若是移动端端请求,则跳转此地址
当ios或android不为空时优先ios或android
https://www.70i.cn
ios String 设备路由,如若是苹果端请求,则跳转此地址 https://www.70i.cn
android String 设备路由,如若是安卓端请求,则跳转此地址 https://www.70i.cn
响应参数
参数 类型 是否必填 描述 示例值
code Int 0,请求成功
并不等于生成成功,生成成功请看Data参数的status字段
0
msg String 消息 success
data Array 结果数据 [{"status":1,"title":"Y20190609180450","url":"https://70i.cn/exTrEZ","expire":1561995514}]
Data参数
参数 类型 是否必填 描述 示例值
status Int 1,生成成功
0,生成失败
1
title String URL标题 Y20190609180450
url String 短网址 https://70i.cn/exTrEZ
expire Int 过期时间戳 1561995514
请求示例
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpStatus;
import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
import org.apache.commons.httpclient.methods.GetMethod;
import org.apache.commons.httpclient.methods.PostMethod;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
public class HttpUtils2 {
private static MultiThreadedHttpConnectionManager connectionManager = null;
private static HttpClient client;
static {
connectionManager = new MultiThreadedHttpConnectionManager();
client = new HttpClient(connectionManager);
}
public static String URLGet( ) {
String response = "";
GetMethod getMethod = null;
StringBuffer strtTotalURL = new StringBuffer("https://api.70i.cn/api?key=您的KEY&url=https://www.70i.cn&title=abc&expire=30&pass=123456&is_wx=1");
try {
getMethod = new GetMethod(strtTotalURL.toString());
getMethod.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=utf-8" );
int statusCode = client.executeMethod(getMethod);
if (statusCode == HttpStatus.SC_OK) {
response = getMethod.getResponseBodyAsString();
} else {
System.out.println("get请求响应状态码 = " + getMethod.getStatusCode());
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if (getMethod != null) {
getMethod.releaseConnection();
getMethod = null;
}
}
System.out.println("get请求返回报文:"+response);
return response;
}
public static void main(String[] args) throws Exception {
URLGet();
}
}
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpStatus;
import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
import org.apache.commons.httpclient.methods.GetMethod;
import org.apache.commons.httpclient.methods.PostMethod;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
public class HttpUtils2 {
private static MultiThreadedHttpConnectionManager connectionManager = null;
private static HttpClient client;
static {
connectionManager = new MultiThreadedHttpConnectionManager();
client = new HttpClient(connectionManager);
}
public static String URLPost() {
String response = "";
PostMethod postMethod = null;
Map<String, Object> params=new HashMap<>();
params.put("url","https://www.70i.cn__https://www.70i.cn");
params.put("title","abc");
//map.put("expire","custom");
params.put("pass","123456");
params.put("is_wx","1");
try {
postMethod = new PostMethod("https://api.70i.cn/api?key=您的KEY");
postMethod.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=utf-8" );
//将表单的值放入postMethod中
Set<String> keySet = params.keySet();
for (String key : keySet) {
Object value = params.get(key);
postMethod.addParameter(key, String.valueOf(value));
}
int statusCode = client.executeMethod(postMethod);
if (statusCode == HttpStatus.SC_OK) {
response = postMethod.getResponseBodyAsString();
} else {
System.out.println("post请求响应状态码 = " + postMethod.getStatusCode());
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if (postMethod != null) {
postMethod.releaseConnection();
postMethod = null;
}
}
System.out.println("post请求返回报文:"+response);
return response;
}
public static void main(String[] args) throws Exception {
URLPost();
}
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.70i.cn/api?key=您的KEY&url=https://www.70i.cn&title=abc&expire=30&pass=123456&is_wx=1');
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
$output = curl_exec($ch);
curl_close($ch);
return $output;
$Data=[
'url' => 'https://www.70i.cn__https://www.70i.cn',
'title'=>'abc',
'expire'=>'custom',
'expire_date'=>'2019-6-9',
'pass'=>'123456',
'is_wx'=>1,
'pc'=>'https://www.70i.cn',
'android'=>'https://www.70i.cn'
];
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,'https://api.70i.cn/api?key=您的KEY');
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($Data));
curl_setopt($ch, CURLOPT_HTTPHEADER, [ 'Content-Type: application/json', 'Content-Length: ' . strlen(json_encode($Data))] );
/**依赖jQuery库,使用AJAX*/
$.ajax({
url:'https://api.70i.cn/api?key=您的KEY&url=https://www.70i.cn&title=abc&expire=30&pass=123456&is_wx=1',
type:'get',
data:'',
dataType:'json',
error:function(err){},
success:function(ret){console.log(ret);}
});
/**依赖jQuery库,使用AJAX*/
$Data={
"url":"https://www.70i.cn__https://www.70i.cn",
"title":"abc",
"expire":"custom",
"expire_date":"2019-6-9",
"pass":"123456",
"is_wx":1,
"pc":"https://www.70i.cn",
"mobile":"https://www.70i.cn",
"ios":"https://www.70i.cn",
"android":"https://www.70i.cn",
};
$.ajax({
url:'https://api.70i.cn/api?key=您的KEY',
type:'post',
data:$Data,
dataType:'json',
error:function(err){},
success:function(ret){console.log(ret);}
});
/// <summary>
/// Get请求
/// </summary>
/// <returns></returns>
static async Task GetAPI()
{
using (HttpClient client = new HttpClient())
{
try {
HttpResponseMessage response = await client.GetAsync($"https://api.70i.cn/api?key=您的KEY&url=https://www.70i.cn&title=首页&expire=1");
response.EnsureSuccessStatusCode();
string responseBody = await response.Content.ReadAsStringAsync();
Console.WriteLine("服务器返回信息:" + responseBody);
} catch (HttpRequestException e) {
Console.WriteLine($"请求异常 :{e.Message} ");
} } }
/// <summary>
/// Post请求
/// </summary>
/// <returns></returns>
static async Task PostAPI()
{
var uri = $"https://api.70i.cn/api?key=您的KEY";
using (var httpclient = new HttpClient())
{
try {
httpclient.BaseAddress = new Uri(uri);
var content = new FormUrlEncodedContent(new Dictionary<string, string>() {
{"url", "https://www.baidu.com"},
{"title", "Bootstrap"},
{"pc" ,"https://www.baidu.com"},
{"mobile" ,"http://m.baidu.com/"}
});
var response = await httpclient.PostAsync(uri, content);
response.EnsureSuccessStatusCode();
string responseString = await response.Content.ReadAsStringAsync();
Console.WriteLine(responseString);
}catch (Exception e){
Console.WriteLine($"请求异常 :{e.Message} ");
}}}
状态码
Code 描述
0 成功
1001 Key字段不存在
1002 Key不存在
1003 用户不存在
1004 用户状态异常
1005 请求类型不正确,只支持GET|POST
1006 要缩短的Url不存在
1007 套餐已过期,购买中购买套餐增加期限
1008 您的可生成短网址配额已用尽,购买中购买套餐增加配额
1009 缺少expire_date字段
1010 该地址池不存在,请联系管理员解决

准备工作

您需要先注册一个账号,获取KEY。
请求地址
请求类型 HTTPS请求地址
GET https://api.70i.cn/ret
请求参数
参数 类型 是否必填 描述 示例值
key String 从平台获取的KEY 20a07baf6a0ee9e9e5efd6fbc250b15c
url String 要缩短的网址 https://api.70i.cn
响应示例
失败则无返回
https://api.70i.cn/adbjs
请求示例
https://api.70i.cn/ret?key=您的KEY&url=https://www.70i.cn

Copyright © 2019 70i.cnAll Rights Reserved.

本站禁止违法违规内容、支付页面或未经备案的网站生成短网址,如有发现立刻封停!

联系客服:点击这里给我发消息 70i短网址

桂ICP备15004580号