php自动获取当前url然后post到远程接收地址的写法!求指导

windsay 发布于 2014/10/20 22:22
阅读 1K+
收藏 0
PHP

【开源中国 APP 全新上线】“动弹” 回归、集成大模型对话、畅读技术报告”

我想写个每当访问一个php文件自动获取当前的php文件URL,然后发送到远程服务接收端,远程接收后,将该地址保存在一个以日期命名的txt文件里面。下面是我写的接收文件。但是那个负责发送的php文件不知道怎么写,没思路,求解答!谢谢!

需要post的参数URL:

$url='http://'.$_SERVER['SERVER_NAME'].':'.$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"]; 

echo $url;



 接收文件:
<?php
ini_set("date.timezone","Asia/Chongqing");
$tim=date('Y-m-d H:i:s',time());
@$url=@$_POST["url"];
@$answer="answer";

function file_add($file_name,$file_data)  
{
$fp=fopen($file_name.".txt","a+");
fputs($fp,$file_data);
fputs($fp,"\r\n");
fclose($fp);
}

if ($url!="")
{
	$data=$url."|".$answer;
	echo $data;
	file_add($tim,$data);
}

?>
加载中
0
eechen
eechen
PHP用curl发出请求,POST数据(URL信息)到远程服务器,远程服务器用$_POST接收数据。
http://cn2.php.net/manual/zh/function.curl-setopt.php
http://www.php100.com/html/php/lei/2013/0905/5365.html
windsay
windsay
thanks。。完美解决!
windsay
windsay
嗯。我试试
OSCHINA
登录后可查看更多优质内容
返回顶部
顶部