Cloak IP屏蔽系统 | 打Facebook仿牌广告 | 跑Google仿品广告
咨询热线
7*24小时在线咨询:

15260825026

接口说明

接口说明

接口使用说明,开始安装代码前,请务必仔细阅读接口文档。如有需要,可联系QQ: 2315518571

1.请求方式:POST

2.请求接口地址:http://dashboard.cloakapi.com/api/ipdetect.json

3.认证方式:HTTP head 参数

参数 必需 示例 描述
Authorization 33323:xxxxxx 认证 username 加 password,冒号分割

4.请求参数:

参数 必需 示例 描述
ip 10.49.0.12 IP可以是IPv4格式,也可以是IPv6格式,获取IP的函数可以查看文章末尾的备注。
country US,GB,CA,AU,IE,NZ 根据您的实际需要填写广告国家的iso_code_2代码, 多个国家代码请使用英文逗号隔开,更多国家的iso_code_2代码,请不要在网上随意查找,以免跟我们接口的有误差,请务必严格从此链接获取:点我查看国家代码
domain test.com 调用接口的域名。

5.代码示例:

PHP版本:

$jsonData = array();                                // 初始化接口发送数据
if (isset($_SERVER['HTTP_CF_CONNECTING_IP'])) {     // 使用cloudflare 转发的IP地址
    $ip = $_SERVER['HTTP_CF_CONNECTING_IP'];
} else {
    if (getenv('HTTP_CLIENT_IP') && strcasecmp(getenv('HTTP_CLIENT_IP'), 'unknown')) {
        $ip = getenv('HTTP_CLIENT_IP');
    } elseif (getenv('HTTP_X_FORWARDED_FOR') && strcasecmp(getenv('HTTP_X_FORWARDED_FOR'), 'unknown')) {
        $ip = getenv('HTTP_X_FORWARDED_FOR');
    } elseif (getenv('REMOTE_ADDR') && strcasecmp(getenv('REMOTE_ADDR'), 'unknown')) {
        $ip = getenv('REMOTE_ADDR');
    } elseif (isset($_SERVER['REMOTE_ADDR']) && $_SERVER['REMOTE_ADDR'] && strcasecmp($_SERVER['REMOTE_ADDR'], 'unknown')) {
        $ip = $_SERVER['REMOTE_ADDR'];
    }
}
$boolean = true;
$hostname = gethostbyaddr($ip);
if (!empty($hostname)) {
    if(is_numeric(stripos($hostname, 'google')) || is_numeric(stripos($hostname, 'bing')) || is_numeric(stripos($hostname, 'facebook')) || is_numeric(stripos($hostname, 'microsoft'))) {
        $boolean = false;
    }
}
if($boolean) {
    $country = 'US,GB,CA,AU,IE,NZ';                     // 根据您的实际需要填写广告国家的iso_code_2代码, 例如你想打美国和英国广告, 就设置 $country = 'US,GB';
    // 更多国家的iso_code_2代码,请不要在网上随意查找,以免跟我们接口的有误差,请务必严格从此链接获取:http://www.cloakapi.com/guojiadaima.html

    $visit_domain = str_replace('www.', '', $_SERVER['HTTP_HOST']);     // 当前网站域名
    $jsonData['ip'] = $ip;
    $jsonData['country'] = $country;
    $jsonData['domain'] = $visit_domain;
    $ch = curl_init('http://dashboard.cloakapi.com/api/ipdetect.json');
    curl_setopt($ch, CURLOPT_USERPWD, "username:password");
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($jsonData));
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    $return = curl_exec($ch);
    $return = json_decode($return, true);
    $boolean = $return['result'];           // 返回true 访问仿品,返回false 访问正品
}
            

java版本:

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Calendar;

import it.sauronsoftware.base64.Base64;

public class IpCloakTest
{
	public static final String CLOAK_USERNAME = "***";

	public static final String CLOAK_PASSWORD = "***";

	public static final String CLOAK_URL = "http://dashboard.cloakapi.com/api/ipdetect.json";

	public static void main(String[] args)
	{
		String paramData = getParamData("***", "US", "***");
		long current = Calendar.getInstance().getTimeInMillis();
		String rspData = getURLContentByConnection(CLOAK_URL, paramData);
		System.out.println("cost time:" + (Calendar.getInstance().getTimeInMillis() - current) + "ms");
		System.out.println(rspData);
	}

	public static String getParamData(String ip, String country, String domain)
	{
		return "ip=" + ip + "&country=" + country + "&domain=" + domain;
	}

	public static String getURLContentByConnection(String url, String value)
	{
		HttpURLConnection httpCon;
		StringBuffer sb = new StringBuffer();
		try
		{
			URL httpUrl = new URL(url);
			httpCon = (HttpURLConnection) httpUrl.openConnection();
			httpCon.setRequestMethod("POST");
			httpCon.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36)"); //防止报403错误
			httpCon.setRequestProperty("Authorization", "Basic " + Base64Code(CLOAK_USERNAME + ":" + CLOAK_PASSWORD));
			httpCon.setUseCaches(false);
			httpCon.setDoOutput(true);
			httpCon.setDoInput(true);
            PrintWriter printWriter = new PrintWriter(httpCon.getOutputStream());
            printWriter.write(value);
            printWriter.flush();

			BufferedReader in = new BufferedReader(new InputStreamReader(
					httpCon.getInputStream(), "utf-8"));
			String line;
			while ((line = in.readLine()) != null)
			{
				sb.append(line);
			}
		}
		catch (IOException e)
		{
			return "exception";
		}
		return sb.toString();
	}

	 /**
     * 二进制数据编码为BASE64字符串
     */
    public static String Base64Code(String Message)
    {
        return new String(Base64.encode(Message.getBytes()));
    }
}
            

asp.net版本:

string Authorization = "username:passwd";
string IP = GetClientIp();
string country = "US,GB,CA,AU,IE";
string domain = Request.ServerVariables["HTTP_HOST"].ToString();
string paramData =
        "ip=" + IP +
        "&country=" + country +
        "&domain=" + domain;

Response.Write(PageHelper.GetHttpPost("http://dashboard.cloakapi.com/api/ipdetect.json"), paramData);

public class PageHelper {
    public static string GetHttpPost(string url, string value)
    {
        byte[] data = Encoding.UTF8.GetBytes(value);
        // Prepare web request
        HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(url);
        myRequest.Method = "POST";
        myRequest.Headers.Add("Authorization", "Basic " + Base64Code("username:passwd"));

        myRequest.ContentType = "application/x-www-form-urlencoded";
        myRequest.ContentLength = data.Length;
        Stream newStream = myRequest.GetRequestStream();

        //Send data
        newStream.Write(data, 0, data.Length);
        newStream.Close();

        //Get response
        HttpWebResponse myResponse = (HttpWebResponse)myRequest.GetResponse();
        StreamReader reader = new StreamReader(myResponse.GetResponseStream(), Encoding.UTF8);
        string content = reader.ReadToEnd();
        return content;
    }

    public static string Base64Code(String Message)
    {
        byte[] bytes = Encoding.Default.GetBytes(Message);
        return Convert.ToBase64String(bytes);
    }?
}?
            
用手机扫描二维码关闭
二维码