开发文档

或者使用链接(key in URL)请求,如:
http://api.3023data.com/apple/activationlock?key=key&sn=359167074097936

Request Timeout 请求超时时间

300秒
为了防止不可预期的网络波动,请设置足够长的请求超时时间,最长300秒。
如:curl_setopt($ch,CURLOPT_TIMEOUT,300);

并发/线程数限制

对于耗时 1 秒以上的查询,并发/线程数控制在 10 及以内
原因:过高并发会导致直接判定为无效或不存在(404)。
其他毫秒级响应的服务无并发/线程数限制。

接口错误码所有接口错误码一致

400Bad Request请求参数错误
404Not Found无效或不存在
502Bad Gateway不支持或查询失败
503Service Unavailable繁忙或者临时维护,请稍后重试
410Gone接口已失效/下线

code = 错误码 (int),message = 错误信息 (string)
查询成功:code===0
每次请求均会返回 cost(扣费) 和 balance(余额),方便随时记录和监控
错误(400)和无效(404)扣费 0.02 元,其他错误不扣费

用户错误码

401Unauthorized密钥无效
402Payment Required余额不足
403Forbidden无权限(IP白名单限制)

接口具体错误信息见 message
如果前端需要返回错误信息,请直接返回 message 的内容

查询成功 code===0

{
	"code": 0,
	"data": {
		"sn": "354434065184270",
		"model": "iPhone 6",
		"fmi": "On"
	},
	"source": "f-i",
	"cost": 0.4,  //扣费
	"balance": 3023  //余额(随时记录和监控余额变化)
}

* 可在每次请求时判断余额到达阈值时触发相应预警逻辑

查询失败

{
	"code": 400,  //错误码
	"message": "请输入正确的IMEI/序列号",  //错误信息
	"cost": 0.02,
	"balance": 3023
}

PHP

<?php
$sn = trim($_GET["sn"]);

$conf = array(
    'key'=>'key',
    'url'=>'http://api.3023data.com/apple/activationlock?sn='.$sn,
    'timeout'=>300
    );

$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,$conf['url']);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
curl_setopt($ch,CURLOPT_HTTPHEADER,array('key: '.$conf['key']));
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,false);
curl_setopt($ch,CURLOPT_SSL_VERIFYHOST,false);
curl_setopt($ch,CURLOPT_DNS_CACHE_TIMEOUT,28800);
curl_setopt($ch,CURLOPT_TIMEOUT,$conf['timeout']);
curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,10);
$resp = curl_exec($ch);
curl_close($ch);

//echo $resp;

$array = json_decode($resp, true);

if($array['code']===0){  //查询成功(code===0)
	print_r($array);  //返回查询结果
}else{  //查询失败
	if($array['message']){  //可根据情况判断错误码
		echo $array['message'];  //返回错误信息
	}else{
		echo 'Error :'.$resp;  //请求失败(连接超时/网络故障/HTTP 404/服务器无响应等)
	}
}

JAVA

public static void main(String[] args) {
String host = "http://api.3023data.com";
String path = "/apple/activationlock";
String method = "GET";
String key = "key";
Map headers = new HashMap();

headers.put("key", key);
Map querys = new HashMap();
querys.put("sn", "359167074097936");

try {
	HttpResponse response = HttpUtils.doGet(host, path, method, headers, querys);
	System.out.println(response.toString());
	//获取response的body
	//System.out.println(EntityUtils.toString(response.getEntity()));
} catch (Exception e) {
	e.printStackTrace();
}
}

Python

import urllib, urllib2, sys
import ssl

host = 'http://api.3023data.com'
path = '/apple/activationlock'
method = 'GET'
key = 'key'
querys = 'sn=359167074097936'
bodys = {}
url = host + path + '?' + querys

request = urllib2.Request(url)
request.add_header('key', key)
ctx = ssl.create_default_context()
ctx.check_hostname = False
ctx.verify_mode = ssl.CERT_NONE
response = urllib2.urlopen(request, context=ctx)
content = response.read()
if (content):
    print(content)

cURL

curl -i -k --get --include 'http://api.3023data.com/apple/activationlock?sn=359167074097936'  -H 'key: key'

Objective-C

NSString *key = @"key";
NSString *host = @"http://api.3023data.com";
NSString *path = @"/apple/activationlock";
NSString *method = @"GET";
NSString *querys = @"?sn=359167074097936";
NSString *url = [NSString stringWithFormat:@"%@%@%@",  host,  path , querys];
NSString *bodys = @"";

NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString: url]  cachePolicy:1  timeoutInterval:  5];
request.HTTPMethod  =  method;
[request addValue:  [NSString  stringWithFormat:@"%@" ,  key]  forHTTPHeaderField:  @"key"];
NSURLSession *requestSession = [NSURLSession sessionWithConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration]];
NSURLSessionDataTask *task = [requestSession dataTaskWithRequest:request
    completionHandler:^(NSData * _Nullable body , NSURLResponse * _Nullable response, NSError * _Nullable error) {
    NSLog(@"Response object: %@" , response);
    NSString *bodyString = [[NSString alloc] initWithData:body encoding:NSUTF8StringEncoding];

    NSLog(@"Response body: %@" , bodyString);
    }];

[task resume];

微信公众号开发