那么你可以使用CURL
/* Some params you wish to send */
$sEncodedParams = 'foo=Bar%20Baz&key=1234';
/* Create a new CURL Object */
$ch = curl_init();
/* Set the URL */
curl_setopt($ch, CURLOPT_URL, $sUrl);
/* Make CURL use POST */
curl_setopt($ch, CURLOPT_POST, true);
/* Add the POST-Data */
curl_setopt($ch, CURLOPT_POSTFIELDS, $sEncodedParams);
/* SET the Headers */
curl_setopt($ch, CURLOPT_HEADER, 0);
/* Execute the request */
curl_exec($ch);
/* Close CURL */
curl_close($ch);
你甚至可以得到的回应方法是使用下面
/* Tell CURL to return the response into a variable instead of echoing it */
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
/* Save the response */
$sResponse = curl_exec($ch);
希望这有助于
问候
编辑返回到一个变量:除了SSL支持(不包含CURL
):
/* Timeout */
$iTimeout = 30;
/* EOL style */
$sEOL = "\r\n";
/* Some params you wish to send */
$sEncodedParams = 'foo=Bar%20Baz&key=1234';
/* Initialize the SSL-Socket */
$rSSLSocket = @fsockopen("ssl://www.domain.com", 443, $iError, $sError, $iTimeout);
/* Will contain the response data */
$sResponse = '';
/* If it worked */
if($rSSLSocket !== false) {
/* Put whatever you need here */
fputs($rSSLSocket, 'POST /path/here HTTP/1.0' . $sEOL);
fputs($rSSLSocket, 'Host: www.domain.com' . $sEOL);
fputs($rSSLSocket, 'Content-type: application/x-www-form-urlencoded' . $sEOL);
fputs($rSSLSocket, 'Content-Length: ' . strlen($sEncodedParams) . $sEOL);
fputs($rSSLSocket, 'Connection: close' . $sEOL . $sEOL);
fputs($rSSLSocket, $sEncodedParams);
while(!feof($rSSLSocket)) {
$sResponse .= @fgets($rSSLSocket, 2048);
}
fclose($rSSLSocket);
} else {
// ERROR
}
我希望这会有所帮助。但要小心,因为fsockopen
可能会很棘手
如果您的网站没有PHP功能,你会怎么使用cURL? – shadyyx
因为请求已发送到我的服务器,它有PHP。这只是论坛网站不允许的。 – CJxD
curl允许你提出额外的请求。它不允许您为用户发布发布请求。 – Ikke