1
我已經完成了一個創建高分辨率圖像的Flash應用程序。我試圖通過php腳本將此圖像作爲產品添加到ZenCart中。我想通過curl訪問管理員,添加一個新產品,如果成功,返回新創建的產品ID。通過CURL動態添加產品到ZenCart
這將是腳本的登錄部分:
$curl = curl_init();
$fields = array('admin_name'=>'user', 'admin_pass'=>'pass');
$url = 'http://www.mystore.com/login.php';
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $fields);
$result = curl_exec($curl);
if(curl_errno($curl)){
echo 'error';
} else {
echo $result;
}
可惜我只收到以下錯誤信息:
Authorization Required
This server could not verify that you are authorized to access the document requested. Either you supplied the wrong credentials (e.g., bad password), or your browser doesn't understand how to supply the credentials required.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
我已經嘗試使用
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
沒有成功。有任何想法嗎?
在此先感謝