fsockopen适用于本地但不适用于服务器

时间:2014-08-07 16:30:42

标签: php ubuntu http-status-code-404 wamp fsockopen

我正在使用WAMP在我的计算机上进行开发,一切正常,但是当我在我的服务器上运行代码时,它返回404.不知道它可能是什么?

我100%确定文件存在且存在,我可以使用浏览器访问它。

这是我的代码:

function resetValidRecipesCache(){

require_once("diet/ValidRecipesCache.php");

$url = "http://" . $GLOBALS['domain_name']. '/services/diet/resetValidRecipesCache.php';

$parts=parse_url($url);

$fp = fsockopen($parts['host'],
    isset($parts['port'])?$parts['port']:80,
    $errno, $errstr, 1000);

$post_string = "memberId=" . getAuthMemberId();

$out = "POST ".$parts['path']." HTTP/1.1\r\n";
$out.= "Host: ".$parts['host']."\r\n";
$out.= "Content-Type: application/x-www-form-urlencoded\r\n";
$out.= "Content-Length: ".strlen($post_string)."\r\n";
$out.= "Connection: Close\r\n\r\n";
if (isset($post_string)) $out.= $post_string;

fwrite($fp, $out);

fwrite($fp, $out);
while (!feof($fp)) {
    echo fgets($fp, 128);
}
fclose($fp);
exit;
}

0 个答案:

没有答案
相关问题