php 模拟post发送数据、接收返回信息、接口相关 等问题。

A 服务器 的a.php post数据到 B服务器的 b.php然后 B服务器的 b.php处理完数据后 将结果以 http://x.x.x.x/xx/a.php?result=xx 的形式返回给 A服务器 的a.php页面(与前面提到的a.php是同一个页面)。 在a.php我用socket (POST方式)发送数据部分代码如下: $request.="POST ".$URL_Info["path"]." HTTP/1.1\n";
$request.="Host: ".$URL_Info["host"]."\n";
$request.="Referer: $referrer\n";
$request.="Content-type: application/x-www-form-urlencoded\n";
$request.="Content-length: ".strlen($data_string)."\n";
$request.="Connection: close\n";
$request.="\n";
$request.=$data_string."\n"; //$data_string是发送的数据 $fp = fsockopen($URL_Info["host"],$URL_Info["port"]);
fputs($fp, $request);
while(!feof($fp)) {
$result .= fgets($fp, 128);
}
fclose($fp); 关于这一句:$result .= fgets($fp, 128);我怎样才能取得 result=xx ??求高人指点。。。

你是要取到B处理完后的返回状态,还是说要取B处理完后调用A的a.php时所带的参数,如果只是取所带的参数,你在a.php 里面直接$_GET['result']就取到了,
温馨提示:答案为网友推荐,仅供参考
第1个回答  2013-05-08
你是要取到B处理完后的返回状态,还是说要取B处理完后调用A的a.php时所带的参数,如果只是取所带的参数,你在a.php 里面直接$_GET['result']就取到了,
相似回答