0
我最近改變了服務器,並且我的一個腳本沒有在新服務器上運行,因爲fopen沒有啓用?轉換fopen捲曲?
是否可以改變下面的代碼來改爲使用CURL函數?
希望有人能幫助!
<?php
$postToFileName = 'http://www.somesite.com/postfile.aspx';
$postArr = array(
'NM' => $row['Lead_Name'],
'EM' => $row['Lead_Email'],
'PH' => $row['Lead_Tel'],
);
$opts = array(
'http'=>array(
'method' => 'POST',
'header' => "Content-type: application/x-www-form-urlencoded\r\n",
'content' => http_build_query($postArr)
)
);
$context = stream_context_create($opts);
$fp = fopen($postToFileName, 'r', false, $context);
$returnedMessage = '';
while (!feof($fp)) {
$returnedMessage .= fgets($fp);
}
fclose($fp);
if ($returnedMessage == '') {
$returnedMessage = 'No Message';
} else if (strlen($returnedMessage) > 250) {
$returnedMessage = substr($returnedMessage,0,250);
}
$returnedMessage = preg_replace("/[\r\n]/", '', $returnedMessage);
$returnedMessage = mysql_real_escape_string($returnedMessage, $sql);
$q = "UPDATE leads SET Data_Sent = '$returnedMessage' WHERE Lead_ID = $id";
mysql_query($q, $sql);
array_push($leadsSent, $id);
}
}
mysql_close($sql);
return $leadsSent;
}
?>