$ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'http://127.0.0.1:5984/_all_dbs'); curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); $result = curl_exec($ch); curl_close($ch); print_r(json_decode($result,true));
PUT方式向songs数据库插入一首歌曲信息
$putString = json_encode(array('name' => 'test','icon' => 'aa')); $putData = tmpfile(); fwrite($putData, $putString); fseek($putData, 0); $ch = curl_init() curl_setopt($ch, CURLOPT_URL, 'http://127.0.0.1:5984/songs/*'.uniqid().'*'); curl_setopt($ch, CURLOPT_PUT, 1); curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); curl_setopt($ch, CURLOPT_INFILE, $putData); curl_setopt($ch, CURLOPT_INFILESIZE, strlen($putString)); $result = curl_exec($ch); fclose($putData); curl_close($ch); print_r(json_decode($result,true));
取指定键名的歌曲信息
$ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'http://127.0.0.1:5984/songs/*4d7edf83b2648*'); curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); $result = curl_exec($ch); curl_close($ch); print_r(json_decode($result,true));