我正在尋找關於以下代碼的指導。我是在從csv文件中提取數據並將每行提交到捲曲URL url
firstname,lastname,address,state,zip,email,homephone,dob,optindate,ipaddress,url
Joey,Demo,4004 S. Louise Ave. 206,Sioux Falls,SD,57106,[email protected],6053231657,06/18/1944,4/19/2008 11:58:34,12.174.252.216,http://www.ecoupons.com
我想添加一些新的變量,將數據轉換爲一個http_build_query並提交每行與POST的URL格式衆多大型CSV文件。
這裏是我的代碼
$processid = '123454r4rt5rt5rtr';
$version = '1.0.0';
$partnercode = 'ABC';
$listid = 'ID12345';
$fp= fopen("test.csv", "r");
while (!feof($fp)) {
list($firstname,$lastname,$address,$city,$state,$zip,$email,$phone,$dob,$optindate,$ipaddress,$url) = fgetcsv($fp);
$data = array('firstname' => $firstname,
'lastname' => $lastname,
'address' => $address,
'city' => $city,
'state' => $state,
'zip' => $zip,
'email' => $email,
'homephone' => $phone,
'dob' => $dob,
'optindate' => $optindate,
'ipaddress' => $ipaddress,
'url' => $url,
'processid' => $partnercode,
'version' => $version,
'partnercode' => $partnercode,
'listid' => $listid);
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://localhost.com');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt(CURLOPT_USERPWD, 'usernameassword')
$data = curl_exec($ch);
curl_close($ch);
當我測試,現在我不斷收到意想不到的T_VARIABLE,但我不是100%肯定我的編碼是正確的。
在此先感謝。
您正在收到的錯誤是語法錯誤。可能你忘了用分號終止一行 – Lix