我一直在试图在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
{“错误”:“未授权”,“原因”:“名称或密码不正确”} –