我一直在試圖在PHP上使用curl的例子。但是,沒有我嘗試的作品。我想要做的只是使用PHP讀取,寫入,搜索有關混亂的數據。但是,對於初學者來說,這似乎不是一個簡單的方法。如何使用PHP讀取和寫入cloudant
代碼在這裏:
//Get DB's
$returned_content = get_data('https://**InstanceName**:**Password**@**InstanceName**.cloudant.com/_all_dbs');
function get_data($url)
{
$ch = curl_init();
$timeout = 5;
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
我得到的錯誤是:
{"error":"unauthorized","reason":"Name or password is incorrect"}
cloudant API密鑰是什麼錯誤? – Mark
{「錯誤」:「未授權」,「原因」:「名稱或密碼不正確」} –