2
请原谅我的英文不好。如何通过curl在php中调用mongodb rest api?
我是新来的mongolab.I想知道如何通过curl调用mongolad rest api。
我不想使用mongodb驱动程序。
在此先感谢。
请原谅我的英文不好。如何通过curl在php中调用mongodb rest api?
我是新来的mongolab.I想知道如何通过curl调用mongolad rest api。
我不想使用mongodb驱动程序。
在此先感谢。
试试这个(与你的API密钥形式MongoLab替换myApiKey):
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.mongolab.com/api/1/databases?apiKey=myAPIKey");
curl_setopt($ch, CURLOPT_USERAGENT, "MongolabBot/1.0");
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
curl_close($ch);