我有一个简单的问题要问。我使用CURL使用post字段将数据发送到目标服务器。我使用以下代码,
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL, $url);
curl_setopt($ch,CURLOPT_POST, count($_POST));
curl_setopt($ch,CURLOPT_POSTFIELDS, $postStr);
$result = curl_exec($ch);
curl_close($ch);
然后我使用
捕获数据$post = $_POST;
那么无论如何我可以确定卷曲数据来自哪个服务器?由于它来自5个不同的服务器。我想捕获发送帖子的源的URL。感谢
答案 0 :(得分:0)
在cURL程序中使用详细模式(-v)。
示例:
C:\curl www.google.com
<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>302 Moved</TITLE></HEAD><BODY>
<H1>302 Moved</H1>
The document has moved
<A HREF="http://www.google.com.br/?gfe_rd=cr&ei=Y76WVbuaAvGp8wf42oGADw">here</A>.
</BODY></HTML>
或者:
C:\curl -v www.google.com
* Rebuilt URL to: www.google.com/
* Trying 216.58.222.4... <<< --- <<< --- YOUR SERVER IS THIS ONE
* Connected to www.google.com (216.58.222.4) port 80 (#0)
> GET / HTTP/1.1
> Host: www.google.com
> User-Agent: curl/7.42.0
> Accept: * / * <
< HTTP/1.1 302 Found
< Cache-Control: private
< Content-Type: text/html; charset=UTF-8
< Location: http://www.google.com.br/?gfe_rd=cr&ei=A76WVZvWCO-p8wf334HIDg
< Content-Length: 262
< Date: Fri, 03 Jul 2015 16:53:23 GMT
< Server: GFE/2.0
< Alternate-Protocol: 80:quic,p=0
<
<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>302 Moved</TITLE></HEAD><BODY>
<H1>302 Moved</H1>
The document has moved
<A HREF="http://www.google.com.br/?gfe_rd=cr&ei=A76WVZvWCO-p8wf334HIDg">here</A>.
</BODY></HTML>
* Connection #0 to host www.google.com left intact