简体   繁体   中英

How do I call mongodb rest api through curl in php?

Execuse me for my bad english.

I am new to mongolab.I want to know how to call mongolad rest api through curl in php.

I don't want to use mongodb driver.

thanks in advance.

Try this (replace myApiKey with your api key form MongoLab):

$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);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM