<?php
//初始化
//POST方式
$data_string['id'] = '8';
$rand_ip = rand(1,255).'.'.rand(1,255).'.'.rand(1,255).'.'.rand(1,255);
$client_ip = "CLIENT-IP:$rand_ip";
$x_forwarded_for = "X-FORWARDED-FOR:$rand_ip";
$header = array(
$client_ip,
$x_forwarded_for
);
$url = "http://www.xxxxx.com/test.php";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS,$data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
//curl_setopt($ch, CURLOPT_PROXY , "60.30.113.232"); //代理设置
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); //取消ssl验证,访问https
//执行并获取接口传的内容
$ret = curl_exec($ch);
curl_close($ch);
print_r($ret); |